Fossil SCM
Ensure that ALL fopen() calls include 'b' in their modes. The git import/export fopen()s did not have this, which may (hypothetically, but unproven) lead to EOL conversion on Windows.
Commit
13049ef2458aa5795b9c9369bec46a28de645f4e0371eb293c9e95953dba65a2
Parent
eabccae174afdf0…
5 files changed
+1
-1
+2
-2
+2
-2
+1
-1
+2
-2
+1
-1
| --- src/backoffice.c | ||
| +++ src/backoffice.c | ||
| @@ -628,11 +628,11 @@ | ||
| 628 | 628 | int nTotal = 0; |
| 629 | 629 | #if !defined(_WIN32) |
| 630 | 630 | struct timeval sStart, sEnd; |
| 631 | 631 | #endif |
| 632 | 632 | if( zLog==0 ) zLog = db_get("backoffice-logfile",0); |
| 633 | - if( zLog && zLog[0] && (backofficeFILE = fossil_fopen(zLog,"a"))!=0 ){ | |
| 633 | + if( zLog && zLog[0] && (backofficeFILE = fossil_fopen(zLog,"ab"))!=0 ){ | |
| 634 | 634 | int i; |
| 635 | 635 | char *zName = db_get("project-name",0); |
| 636 | 636 | #if !defined(_WIN32) |
| 637 | 637 | gettimeofday(&sStart, 0); |
| 638 | 638 | signal(SIGSEGV, backoffice_signal_handler); |
| 639 | 639 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -628,11 +628,11 @@ | |
| 628 | int nTotal = 0; |
| 629 | #if !defined(_WIN32) |
| 630 | struct timeval sStart, sEnd; |
| 631 | #endif |
| 632 | if( zLog==0 ) zLog = db_get("backoffice-logfile",0); |
| 633 | if( zLog && zLog[0] && (backofficeFILE = fossil_fopen(zLog,"a"))!=0 ){ |
| 634 | int i; |
| 635 | char *zName = db_get("project-name",0); |
| 636 | #if !defined(_WIN32) |
| 637 | gettimeofday(&sStart, 0); |
| 638 | signal(SIGSEGV, backoffice_signal_handler); |
| 639 |
| --- src/backoffice.c | |
| +++ src/backoffice.c | |
| @@ -628,11 +628,11 @@ | |
| 628 | int nTotal = 0; |
| 629 | #if !defined(_WIN32) |
| 630 | struct timeval sStart, sEnd; |
| 631 | #endif |
| 632 | if( zLog==0 ) zLog = db_get("backoffice-logfile",0); |
| 633 | if( zLog && zLog[0] && (backofficeFILE = fossil_fopen(zLog,"ab"))!=0 ){ |
| 634 | int i; |
| 635 | char *zName = db_get("project-name",0); |
| 636 | #if !defined(_WIN32) |
| 637 | gettimeofday(&sStart, 0); |
| 638 | signal(SIGSEGV, backoffice_signal_handler); |
| 639 |
+2
-2
| --- src/export.c | ||
| +++ src/export.c | ||
| @@ -517,11 +517,11 @@ | ||
| 517 | 517 | if( markfile_in!=0 ){ |
| 518 | 518 | Stmt qb,qc; |
| 519 | 519 | FILE *f; |
| 520 | 520 | int rid; |
| 521 | 521 | |
| 522 | - f = fossil_fopen(markfile_in, "r"); | |
| 522 | + f = fossil_fopen(markfile_in, "rb"); | |
| 523 | 523 | if( f==0 ){ |
| 524 | 524 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 525 | 525 | } |
| 526 | 526 | if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){ |
| 527 | 527 | fossil_fatal("error importing marks from file: %s", markfile_in); |
| @@ -733,11 +733,11 @@ | ||
| 733 | 733 | } |
| 734 | 734 | db_finalize(&q); |
| 735 | 735 | |
| 736 | 736 | if( markfile_out!=0 ){ |
| 737 | 737 | FILE *f; |
| 738 | - f = fossil_fopen(markfile_out, "w"); | |
| 738 | + f = fossil_fopen(markfile_out, "wb"); | |
| 739 | 739 | if( f == 0 ){ |
| 740 | 740 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 741 | 741 | } |
| 742 | 742 | export_marks(f, &blobs, &vers); |
| 743 | 743 | if( ferror(f)!=0 || fclose(f)!=0 ){ |
| 744 | 744 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -517,11 +517,11 @@ | |
| 517 | if( markfile_in!=0 ){ |
| 518 | Stmt qb,qc; |
| 519 | FILE *f; |
| 520 | int rid; |
| 521 | |
| 522 | f = fossil_fopen(markfile_in, "r"); |
| 523 | if( f==0 ){ |
| 524 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 525 | } |
| 526 | if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){ |
| 527 | fossil_fatal("error importing marks from file: %s", markfile_in); |
| @@ -733,11 +733,11 @@ | |
| 733 | } |
| 734 | db_finalize(&q); |
| 735 | |
| 736 | if( markfile_out!=0 ){ |
| 737 | FILE *f; |
| 738 | f = fossil_fopen(markfile_out, "w"); |
| 739 | if( f == 0 ){ |
| 740 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 741 | } |
| 742 | export_marks(f, &blobs, &vers); |
| 743 | if( ferror(f)!=0 || fclose(f)!=0 ){ |
| 744 |
| --- src/export.c | |
| +++ src/export.c | |
| @@ -517,11 +517,11 @@ | |
| 517 | if( markfile_in!=0 ){ |
| 518 | Stmt qb,qc; |
| 519 | FILE *f; |
| 520 | int rid; |
| 521 | |
| 522 | f = fossil_fopen(markfile_in, "rb"); |
| 523 | if( f==0 ){ |
| 524 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 525 | } |
| 526 | if( import_marks(f, &blobs, &vers, &unused_mark)<0 ){ |
| 527 | fossil_fatal("error importing marks from file: %s", markfile_in); |
| @@ -733,11 +733,11 @@ | |
| 733 | } |
| 734 | db_finalize(&q); |
| 735 | |
| 736 | if( markfile_out!=0 ){ |
| 737 | FILE *f; |
| 738 | f = fossil_fopen(markfile_out, "wb"); |
| 739 | if( f == 0 ){ |
| 740 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 741 | } |
| 742 | export_marks(f, &blobs, &vers); |
| 743 | if( ferror(f)!=0 || fclose(f)!=0 ){ |
| 744 |
+2
-2
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -1930,11 +1930,11 @@ | ||
| 1930 | 1930 | "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);" |
| 1931 | 1931 | "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);" |
| 1932 | 1932 | ); |
| 1933 | 1933 | |
| 1934 | 1934 | if( markfile_in ){ |
| 1935 | - FILE *f = fossil_fopen(markfile_in, "r"); | |
| 1935 | + FILE *f = fossil_fopen(markfile_in, "rb"); | |
| 1936 | 1936 | if( !f ){ |
| 1937 | 1937 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 1938 | 1938 | } |
| 1939 | 1939 | if( import_marks(f, &blobs, NULL, NULL)<0 ){ |
| 1940 | 1940 | fossil_fatal("error importing marks from file: %s", markfile_in); |
| @@ -1988,11 +1988,11 @@ | ||
| 1988 | 1988 | }else{ |
| 1989 | 1989 | bag_insert(&vers, rid); |
| 1990 | 1990 | } |
| 1991 | 1991 | } |
| 1992 | 1992 | db_finalize(&q_marks); |
| 1993 | - f = fossil_fopen(markfile_out, "w"); | |
| 1993 | + f = fossil_fopen(markfile_out, "wb"); | |
| 1994 | 1994 | if( !f ){ |
| 1995 | 1995 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 1996 | 1996 | } |
| 1997 | 1997 | export_marks(f, &blobs, &vers); |
| 1998 | 1998 | fclose(f); |
| 1999 | 1999 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1930,11 +1930,11 @@ | |
| 1930 | "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);" |
| 1931 | "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);" |
| 1932 | ); |
| 1933 | |
| 1934 | if( markfile_in ){ |
| 1935 | FILE *f = fossil_fopen(markfile_in, "r"); |
| 1936 | if( !f ){ |
| 1937 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 1938 | } |
| 1939 | if( import_marks(f, &blobs, NULL, NULL)<0 ){ |
| 1940 | fossil_fatal("error importing marks from file: %s", markfile_in); |
| @@ -1988,11 +1988,11 @@ | |
| 1988 | }else{ |
| 1989 | bag_insert(&vers, rid); |
| 1990 | } |
| 1991 | } |
| 1992 | db_finalize(&q_marks); |
| 1993 | f = fossil_fopen(markfile_out, "w"); |
| 1994 | if( !f ){ |
| 1995 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 1996 | } |
| 1997 | export_marks(f, &blobs, &vers); |
| 1998 | fclose(f); |
| 1999 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -1930,11 +1930,11 @@ | |
| 1930 | "CREATE TEMP TABLE xbranch(tname TEXT UNIQUE, brnm TEXT);" |
| 1931 | "CREATE TEMP TABLE xtag(tname TEXT UNIQUE, tcontent TEXT);" |
| 1932 | ); |
| 1933 | |
| 1934 | if( markfile_in ){ |
| 1935 | FILE *f = fossil_fopen(markfile_in, "rb"); |
| 1936 | if( !f ){ |
| 1937 | fossil_fatal("cannot open %s for reading", markfile_in); |
| 1938 | } |
| 1939 | if( import_marks(f, &blobs, NULL, NULL)<0 ){ |
| 1940 | fossil_fatal("error importing marks from file: %s", markfile_in); |
| @@ -1988,11 +1988,11 @@ | |
| 1988 | }else{ |
| 1989 | bag_insert(&vers, rid); |
| 1990 | } |
| 1991 | } |
| 1992 | db_finalize(&q_marks); |
| 1993 | f = fossil_fopen(markfile_out, "wb"); |
| 1994 | if( !f ){ |
| 1995 | fossil_fatal("cannot open %s for writing", markfile_out); |
| 1996 | } |
| 1997 | export_marks(f, &blobs, &vers); |
| 1998 | fclose(f); |
| 1999 |
+1
-1
| --- src/printf.c | ||
| +++ src/printf.c | ||
| @@ -1086,11 +1086,11 @@ | ||
| 1086 | 1086 | "REQUEST_URI", "SCRIPT_NAME" }; |
| 1087 | 1087 | if( g.zErrlog==0 ) return; |
| 1088 | 1088 | if( g.zErrlog[0]=='-' && g.zErrlog[1]==0 ){ |
| 1089 | 1089 | out = stderr; |
| 1090 | 1090 | }else{ |
| 1091 | - out = fossil_fopen(g.zErrlog, "a"); | |
| 1091 | + out = fossil_fopen(g.zErrlog, "ab"); | |
| 1092 | 1092 | if( out==0 ) return; |
| 1093 | 1093 | } |
| 1094 | 1094 | now = time(0); |
| 1095 | 1095 | pNow = gmtime(&now); |
| 1096 | 1096 | fprintf(out, "------------- %04d-%02d-%02d %02d:%02d:%02d UTC ------------\n", |
| 1097 | 1097 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -1086,11 +1086,11 @@ | |
| 1086 | "REQUEST_URI", "SCRIPT_NAME" }; |
| 1087 | if( g.zErrlog==0 ) return; |
| 1088 | if( g.zErrlog[0]=='-' && g.zErrlog[1]==0 ){ |
| 1089 | out = stderr; |
| 1090 | }else{ |
| 1091 | out = fossil_fopen(g.zErrlog, "a"); |
| 1092 | if( out==0 ) return; |
| 1093 | } |
| 1094 | now = time(0); |
| 1095 | pNow = gmtime(&now); |
| 1096 | fprintf(out, "------------- %04d-%02d-%02d %02d:%02d:%02d UTC ------------\n", |
| 1097 |
| --- src/printf.c | |
| +++ src/printf.c | |
| @@ -1086,11 +1086,11 @@ | |
| 1086 | "REQUEST_URI", "SCRIPT_NAME" }; |
| 1087 | if( g.zErrlog==0 ) return; |
| 1088 | if( g.zErrlog[0]=='-' && g.zErrlog[1]==0 ){ |
| 1089 | out = stderr; |
| 1090 | }else{ |
| 1091 | out = fossil_fopen(g.zErrlog, "ab"); |
| 1092 | if( out==0 ) return; |
| 1093 | } |
| 1094 | now = time(0); |
| 1095 | pNow = gmtime(&now); |
| 1096 | fprintf(out, "------------- %04d-%02d-%02d %02d:%02d:%02d UTC ------------\n", |
| 1097 |
+2
-2
| --- src/security_audit.c | ||
| +++ src/security_audit.c | ||
| @@ -608,11 +608,11 @@ | ||
| 608 | 608 | }else{ |
| 609 | 609 | @ add the "--errorlog <i>FILENAME</i>" option to the |
| 610 | 610 | @ "%h(g.argv[0]) %h(g.zCmdName)" command that launched this server. |
| 611 | 611 | } |
| 612 | 612 | }else{ |
| 613 | - FILE *pTest = fossil_fopen(g.zErrlog,"a"); | |
| 613 | + FILE *pTest = fossil_fopen(g.zErrlog,"ab"); | |
| 614 | 614 | if( pTest==0 ){ |
| 615 | 615 | @ <li><p> |
| 616 | 616 | @ <b>Error:</b> |
| 617 | 617 | @ There is an error log at "%h(g.zErrlog)" but that file is not |
| 618 | 618 | @ writable and so no logging will occur. |
| @@ -862,11 +862,11 @@ | ||
| 862 | 862 | no_error_log_available(); |
| 863 | 863 | style_finish_page(); |
| 864 | 864 | return; |
| 865 | 865 | } |
| 866 | 866 | if( P("truncate1") && cgi_csrf_safe(2) ){ |
| 867 | - fclose(fopen(g.zErrlog,"w")); | |
| 867 | + fclose(fopen(g.zErrlog,"wb")); | |
| 868 | 868 | } |
| 869 | 869 | if( P("download") ){ |
| 870 | 870 | Blob log; |
| 871 | 871 | blob_read_from_file(&log, g.zErrlog, ExtFILE); |
| 872 | 872 | cgi_set_content_type("text/plain"); |
| 873 | 873 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -608,11 +608,11 @@ | |
| 608 | }else{ |
| 609 | @ add the "--errorlog <i>FILENAME</i>" option to the |
| 610 | @ "%h(g.argv[0]) %h(g.zCmdName)" command that launched this server. |
| 611 | } |
| 612 | }else{ |
| 613 | FILE *pTest = fossil_fopen(g.zErrlog,"a"); |
| 614 | if( pTest==0 ){ |
| 615 | @ <li><p> |
| 616 | @ <b>Error:</b> |
| 617 | @ There is an error log at "%h(g.zErrlog)" but that file is not |
| 618 | @ writable and so no logging will occur. |
| @@ -862,11 +862,11 @@ | |
| 862 | no_error_log_available(); |
| 863 | style_finish_page(); |
| 864 | return; |
| 865 | } |
| 866 | if( P("truncate1") && cgi_csrf_safe(2) ){ |
| 867 | fclose(fopen(g.zErrlog,"w")); |
| 868 | } |
| 869 | if( P("download") ){ |
| 870 | Blob log; |
| 871 | blob_read_from_file(&log, g.zErrlog, ExtFILE); |
| 872 | cgi_set_content_type("text/plain"); |
| 873 |
| --- src/security_audit.c | |
| +++ src/security_audit.c | |
| @@ -608,11 +608,11 @@ | |
| 608 | }else{ |
| 609 | @ add the "--errorlog <i>FILENAME</i>" option to the |
| 610 | @ "%h(g.argv[0]) %h(g.zCmdName)" command that launched this server. |
| 611 | } |
| 612 | }else{ |
| 613 | FILE *pTest = fossil_fopen(g.zErrlog,"ab"); |
| 614 | if( pTest==0 ){ |
| 615 | @ <li><p> |
| 616 | @ <b>Error:</b> |
| 617 | @ There is an error log at "%h(g.zErrlog)" but that file is not |
| 618 | @ writable and so no logging will occur. |
| @@ -862,11 +862,11 @@ | |
| 862 | no_error_log_available(); |
| 863 | style_finish_page(); |
| 864 | return; |
| 865 | } |
| 866 | if( P("truncate1") && cgi_csrf_safe(2) ){ |
| 867 | fclose(fopen(g.zErrlog,"wb")); |
| 868 | } |
| 869 | if( P("download") ){ |
| 870 | Blob log; |
| 871 | blob_read_from_file(&log, g.zErrlog, ExtFILE); |
| 872 | cgi_set_content_type("text/plain"); |
| 873 |