Fossil SCM
More proposed fixes to the issues pointed out by Edward Berner.
Commit
7807ec4e130b63651f0373683104504dcffb9f64
Parent
3fc62dde2cc5683…
5 files changed
+3
-4
+1
-1
+13
-1
+1
-1
+2
+3
-4
| --- src/cgi.c | ||
| +++ src/cgi.c | ||
| @@ -1596,15 +1596,14 @@ | ||
| 1596 | 1596 | void cgi_handle_scgi_request(void){ |
| 1597 | 1597 | char *zHdr; |
| 1598 | 1598 | char *zToFree; |
| 1599 | 1599 | int nHdr = 0; |
| 1600 | 1600 | int nRead; |
| 1601 | - int n, m; | |
| 1602 | - char c; | |
| 1601 | + int c, n, m; | |
| 1603 | 1602 | |
| 1604 | - while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit(c) ){ | |
| 1605 | - nHdr = nHdr*10 + c - '0'; | |
| 1603 | + while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit((char)c) ){ | |
| 1604 | + nHdr = nHdr*10 + (char)c - '0'; | |
| 1606 | 1605 | } |
| 1607 | 1606 | if( nHdr<16 ) malformed_request("SCGI header too short"); |
| 1608 | 1607 | zToFree = zHdr = fossil_malloc(nHdr); |
| 1609 | 1608 | nRead = (int)fread(zHdr, 1, nHdr, g.httpIn); |
| 1610 | 1609 | if( nRead<nHdr ) malformed_request("cannot read entire SCGI header"); |
| 1611 | 1610 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -1596,15 +1596,14 @@ | |
| 1596 | void cgi_handle_scgi_request(void){ |
| 1597 | char *zHdr; |
| 1598 | char *zToFree; |
| 1599 | int nHdr = 0; |
| 1600 | int nRead; |
| 1601 | int n, m; |
| 1602 | char c; |
| 1603 | |
| 1604 | while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit(c) ){ |
| 1605 | nHdr = nHdr*10 + c - '0'; |
| 1606 | } |
| 1607 | if( nHdr<16 ) malformed_request("SCGI header too short"); |
| 1608 | zToFree = zHdr = fossil_malloc(nHdr); |
| 1609 | nRead = (int)fread(zHdr, 1, nHdr, g.httpIn); |
| 1610 | if( nRead<nHdr ) malformed_request("cannot read entire SCGI header"); |
| 1611 |
| --- src/cgi.c | |
| +++ src/cgi.c | |
| @@ -1596,15 +1596,14 @@ | |
| 1596 | void cgi_handle_scgi_request(void){ |
| 1597 | char *zHdr; |
| 1598 | char *zToFree; |
| 1599 | int nHdr = 0; |
| 1600 | int nRead; |
| 1601 | int c, n, m; |
| 1602 | |
| 1603 | while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit((char)c) ){ |
| 1604 | nHdr = nHdr*10 + (char)c - '0'; |
| 1605 | } |
| 1606 | if( nHdr<16 ) malformed_request("SCGI header too short"); |
| 1607 | zToFree = zHdr = fossil_malloc(nHdr); |
| 1608 | nRead = (int)fread(zHdr, 1, nHdr, g.httpIn); |
| 1609 | if( nRead<nHdr ) malformed_request("cannot read entire SCGI header"); |
| 1610 |
+1
-1
| --- src/diff.c | ||
| +++ src/diff.c | ||
| @@ -594,11 +594,11 @@ | ||
| 594 | 594 | "<td><div class=\"diff%scol\">\n" |
| 595 | 595 | "<pre>\n" |
| 596 | 596 | "%s" |
| 597 | 597 | "</pre>\n" |
| 598 | 598 | "</div></td>\n", |
| 599 | - col % 3 ? (col == SBS_MKR ? "mkr" : "txt") : "ln", | |
| 599 | + (col % 3) ? (col == SBS_MKR ? "mkr" : "txt") : "ln", | |
| 600 | 600 | blob_str(pCol) |
| 601 | 601 | ); |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 | /* |
| 605 | 605 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -594,11 +594,11 @@ | |
| 594 | "<td><div class=\"diff%scol\">\n" |
| 595 | "<pre>\n" |
| 596 | "%s" |
| 597 | "</pre>\n" |
| 598 | "</div></td>\n", |
| 599 | col % 3 ? (col == SBS_MKR ? "mkr" : "txt") : "ln", |
| 600 | blob_str(pCol) |
| 601 | ); |
| 602 | } |
| 603 | |
| 604 | /* |
| 605 |
| --- src/diff.c | |
| +++ src/diff.c | |
| @@ -594,11 +594,11 @@ | |
| 594 | "<td><div class=\"diff%scol\">\n" |
| 595 | "<pre>\n" |
| 596 | "%s" |
| 597 | "</pre>\n" |
| 598 | "</div></td>\n", |
| 599 | (col % 3) ? (col == SBS_MKR ? "mkr" : "txt") : "ln", |
| 600 | blob_str(pCol) |
| 601 | ); |
| 602 | } |
| 603 | |
| 604 | /* |
| 605 |
+13
-1
| --- src/diffcmd.c | ||
| +++ src/diffcmd.c | ||
| @@ -28,10 +28,15 @@ | ||
| 28 | 28 | # define NULL_DEVICE "NUL" |
| 29 | 29 | #else |
| 30 | 30 | # define NULL_DEVICE "/dev/null" |
| 31 | 31 | #endif |
| 32 | 32 | |
| 33 | +/* | |
| 34 | +** Used when the name for the diff is unknown. | |
| 35 | +*/ | |
| 36 | +#define DIFF_NO_NAME "(unknown)" | |
| 37 | + | |
| 33 | 38 | /* |
| 34 | 39 | ** Print the "Index:" message that patches wants to see at the top of a diff. |
| 35 | 40 | */ |
| 36 | 41 | void diff_print_index(const char *zFile, u64 diffFlags){ |
| 37 | 42 | if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){ |
| @@ -489,11 +494,18 @@ | ||
| 489 | 494 | u64 diffFlags |
| 490 | 495 | ){ |
| 491 | 496 | Blob f1, f2; |
| 492 | 497 | int isBin1, isBin2; |
| 493 | 498 | int rid; |
| 494 | - const char *zName = pFrom ? pFrom->zName : pTo->zName; | |
| 499 | + const char *zName; | |
| 500 | + if( pFrom ){ | |
| 501 | + zName = pFrom->zName; | |
| 502 | + }else if( pTo ){ | |
| 503 | + zName = pTo->zName; | |
| 504 | + }else{ | |
| 505 | + zName = DIFF_NO_NAME; | |
| 506 | + } | |
| 495 | 507 | if( diffFlags & DIFF_BRIEF ) return; |
| 496 | 508 | diff_print_index(zName, diffFlags); |
| 497 | 509 | if( pFrom ){ |
| 498 | 510 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 499 | 511 | content_get(rid, &f1); |
| 500 | 512 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -28,10 +28,15 @@ | |
| 28 | # define NULL_DEVICE "NUL" |
| 29 | #else |
| 30 | # define NULL_DEVICE "/dev/null" |
| 31 | #endif |
| 32 | |
| 33 | /* |
| 34 | ** Print the "Index:" message that patches wants to see at the top of a diff. |
| 35 | */ |
| 36 | void diff_print_index(const char *zFile, u64 diffFlags){ |
| 37 | if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){ |
| @@ -489,11 +494,18 @@ | |
| 489 | u64 diffFlags |
| 490 | ){ |
| 491 | Blob f1, f2; |
| 492 | int isBin1, isBin2; |
| 493 | int rid; |
| 494 | const char *zName = pFrom ? pFrom->zName : pTo->zName; |
| 495 | if( diffFlags & DIFF_BRIEF ) return; |
| 496 | diff_print_index(zName, diffFlags); |
| 497 | if( pFrom ){ |
| 498 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 499 | content_get(rid, &f1); |
| 500 |
| --- src/diffcmd.c | |
| +++ src/diffcmd.c | |
| @@ -28,10 +28,15 @@ | |
| 28 | # define NULL_DEVICE "NUL" |
| 29 | #else |
| 30 | # define NULL_DEVICE "/dev/null" |
| 31 | #endif |
| 32 | |
| 33 | /* |
| 34 | ** Used when the name for the diff is unknown. |
| 35 | */ |
| 36 | #define DIFF_NO_NAME "(unknown)" |
| 37 | |
| 38 | /* |
| 39 | ** Print the "Index:" message that patches wants to see at the top of a diff. |
| 40 | */ |
| 41 | void diff_print_index(const char *zFile, u64 diffFlags){ |
| 42 | if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){ |
| @@ -489,11 +494,18 @@ | |
| 494 | u64 diffFlags |
| 495 | ){ |
| 496 | Blob f1, f2; |
| 497 | int isBin1, isBin2; |
| 498 | int rid; |
| 499 | const char *zName; |
| 500 | if( pFrom ){ |
| 501 | zName = pFrom->zName; |
| 502 | }else if( pTo ){ |
| 503 | zName = pTo->zName; |
| 504 | }else{ |
| 505 | zName = DIFF_NO_NAME; |
| 506 | } |
| 507 | if( diffFlags & DIFF_BRIEF ) return; |
| 508 | diff_print_index(zName, diffFlags); |
| 509 | if( pFrom ){ |
| 510 | rid = uuid_to_rid(pFrom->zUuid, 0); |
| 511 | content_get(rid, &f1); |
| 512 |
+1
-1
| --- src/markdown.c | ||
| +++ src/markdown.c | ||
| @@ -390,11 +390,11 @@ | ||
| 390 | 390 | && data[i]!='>' |
| 391 | 391 | && data[i]!='\'' |
| 392 | 392 | && data[i]!='"' |
| 393 | 393 | && data[i]!=' ' |
| 394 | 394 | && data[i]!='\t' |
| 395 | - && data[i]!='\t' | |
| 395 | + && data[i]!='\n' | |
| 396 | 396 | ){ |
| 397 | 397 | i++; |
| 398 | 398 | } |
| 399 | 399 | if( i>=size ) return 0; |
| 400 | 400 | if( i>j && data[i]=='>' ) return i+1; |
| 401 | 401 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -390,11 +390,11 @@ | |
| 390 | && data[i]!='>' |
| 391 | && data[i]!='\'' |
| 392 | && data[i]!='"' |
| 393 | && data[i]!=' ' |
| 394 | && data[i]!='\t' |
| 395 | && data[i]!='\t' |
| 396 | ){ |
| 397 | i++; |
| 398 | } |
| 399 | if( i>=size ) return 0; |
| 400 | if( i>j && data[i]=='>' ) return i+1; |
| 401 |
| --- src/markdown.c | |
| +++ src/markdown.c | |
| @@ -390,11 +390,11 @@ | |
| 390 | && data[i]!='>' |
| 391 | && data[i]!='\'' |
| 392 | && data[i]!='"' |
| 393 | && data[i]!=' ' |
| 394 | && data[i]!='\t' |
| 395 | && data[i]!='\n' |
| 396 | ){ |
| 397 | i++; |
| 398 | } |
| 399 | if( i>=size ) return 0; |
| 400 | if( i>j && data[i]=='>' ) return i+1; |
| 401 |
+2
| --- src/url.c | ||
| +++ src/url.c | ||
| @@ -238,10 +238,11 @@ | ||
| 238 | 238 | zFile = mprintf("%s/FOSSIL", zUrl); |
| 239 | 239 | if( file_isfile(zFile) ){ |
| 240 | 240 | pUrlData->isFile = 1; |
| 241 | 241 | }else{ |
| 242 | 242 | free(zFile); |
| 243 | + zFile = 0; | |
| 243 | 244 | fossil_fatal("unknown repository: %s", zUrl); |
| 244 | 245 | } |
| 245 | 246 | }else{ |
| 246 | 247 | fossil_fatal("unknown repository: %s", zUrl); |
| 247 | 248 | } |
| @@ -249,10 +250,11 @@ | ||
| 249 | 250 | if( pUrlData->isFile ){ |
| 250 | 251 | Blob cfile; |
| 251 | 252 | dehttpize(zFile); |
| 252 | 253 | file_canonical_name(zFile, &cfile, 0); |
| 253 | 254 | free(zFile); |
| 255 | + zFile = 0; | |
| 254 | 256 | pUrlData->protocol = "file"; |
| 255 | 257 | pUrlData->path = ""; |
| 256 | 258 | pUrlData->name = mprintf("%b", &cfile); |
| 257 | 259 | pUrlData->canonical = mprintf("file://%T", pUrlData->name); |
| 258 | 260 | blob_reset(&cfile); |
| 259 | 261 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -238,10 +238,11 @@ | |
| 238 | zFile = mprintf("%s/FOSSIL", zUrl); |
| 239 | if( file_isfile(zFile) ){ |
| 240 | pUrlData->isFile = 1; |
| 241 | }else{ |
| 242 | free(zFile); |
| 243 | fossil_fatal("unknown repository: %s", zUrl); |
| 244 | } |
| 245 | }else{ |
| 246 | fossil_fatal("unknown repository: %s", zUrl); |
| 247 | } |
| @@ -249,10 +250,11 @@ | |
| 249 | if( pUrlData->isFile ){ |
| 250 | Blob cfile; |
| 251 | dehttpize(zFile); |
| 252 | file_canonical_name(zFile, &cfile, 0); |
| 253 | free(zFile); |
| 254 | pUrlData->protocol = "file"; |
| 255 | pUrlData->path = ""; |
| 256 | pUrlData->name = mprintf("%b", &cfile); |
| 257 | pUrlData->canonical = mprintf("file://%T", pUrlData->name); |
| 258 | blob_reset(&cfile); |
| 259 |
| --- src/url.c | |
| +++ src/url.c | |
| @@ -238,10 +238,11 @@ | |
| 238 | zFile = mprintf("%s/FOSSIL", zUrl); |
| 239 | if( file_isfile(zFile) ){ |
| 240 | pUrlData->isFile = 1; |
| 241 | }else{ |
| 242 | free(zFile); |
| 243 | zFile = 0; |
| 244 | fossil_fatal("unknown repository: %s", zUrl); |
| 245 | } |
| 246 | }else{ |
| 247 | fossil_fatal("unknown repository: %s", zUrl); |
| 248 | } |
| @@ -249,10 +250,11 @@ | |
| 250 | if( pUrlData->isFile ){ |
| 251 | Blob cfile; |
| 252 | dehttpize(zFile); |
| 253 | file_canonical_name(zFile, &cfile, 0); |
| 254 | free(zFile); |
| 255 | zFile = 0; |
| 256 | pUrlData->protocol = "file"; |
| 257 | pUrlData->path = ""; |
| 258 | pUrlData->name = mprintf("%b", &cfile); |
| 259 | pUrlData->canonical = mprintf("file://%T", pUrlData->name); |
| 260 | blob_reset(&cfile); |
| 261 |