Commit 8c1a8061 authored by Leif Walsh's avatar Leif Walsh Committed by Yoni Fogel

closes #5530 fix recovery to be more careful about trusting bytes at the

end of the file


git-svn-id: file:///svn/toku/tokudb@48266 c7de825b-a66e-492c-adef-691d508d4ae1
parent 53e33b75
......@@ -508,7 +508,8 @@ generate_log_reader (void) {
fprintf(hf, ";\n");
fprintf(cf, "{\n");
fprintf(cf, " memset(le, 0, sizeof(*le));\n");
fprintf(cf, " {\n long pos = ftell(infile);\n if (pos<=12) return -1;\n }\n");
fprintf(cf, " long pos = ftell(infile);\n");
fprintf(cf, " if (pos<=12) return -1;\n");
fprintf(cf, " int r = fseek(infile, -4, SEEK_CUR); \n");// assert(r==0);\n");
fprintf(cf, " if (r!=0) return get_error_errno();\n");
fprintf(cf, " uint32_t len;\n");
......@@ -518,6 +519,8 @@ generate_log_reader (void) {
fprintf(cf, " if (r!=0) return get_error_errno();\n");
fprintf(cf, " r = toku_log_fread(infile, le); \n");// assert(r==0);\n");
fprintf(cf, " if (r!=0) return 1;\n");
fprintf(cf, " long afterpos = ftell(infile);\n");
fprintf(cf, " if (afterpos != pos) return 1;\n");
fprintf(cf, " r = fseek(infile, -(int)len, SEEK_CUR); \n");// assert(r==0);\n");
fprintf(cf, " if (r!=0) return get_error_errno();\n");
fprintf(cf, " return 0;\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment