Fossil SCM
In import --git, look for the slash in the name on a commit command only within the name, so that a name with no slash after its fifth byte is not read past its end.
Commit
3e2c8b93cdcb55e0ded42245488e2cd1777d16bc24d4f521b846bd758ab5a745
Parent
8db6622be04e7e9…
1 file changed
+6
-3
+6
-3
| --- src/import.c | ||
| +++ src/import.c | ||
| @@ -569,10 +569,11 @@ | ||
| 569 | 569 | gg.xFinish(); |
| 570 | 570 | gg.xFinish = finish_blob; |
| 571 | 571 | }else |
| 572 | 572 | if( strncmp(zLine, "commit ", 7)==0 ){ |
| 573 | 573 | const char *zRefName; |
| 574 | + int nRef; | |
| 574 | 575 | gg.xFinish(); |
| 575 | 576 | gg.xFinish = finish_commit; |
| 576 | 577 | trim_newline(&zLine[7]); |
| 577 | 578 | zRefName = &zLine[7]; |
| 578 | 579 | |
| @@ -592,13 +593,15 @@ | ||
| 592 | 593 | ** last commit that holds that tag. |
| 593 | 594 | ** |
| 594 | 595 | ** None of the above is explained in the git-fast-export |
| 595 | 596 | ** documentation. We had to figure it out via trial and error. |
| 596 | 597 | */ |
| 597 | - for(i=5; i<(int)strlen(zRefName) && zRefName[i]!='/'; i++){} | |
| 598 | - gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */ | |
| 599 | - if( zRefName[i+1]!=0 ) zRefName += i+1; | |
| 598 | + nRef = (int)strlen(zRefName); | |
| 599 | + for(i=5; i<nRef && zRefName[i]!='/'; i++){} | |
| 600 | + gg.tagCommit = nRef>=9 | |
| 601 | + && strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */ | |
| 602 | + if( i<nRef && zRefName[i+1]!=0 ) zRefName += i+1; | |
| 600 | 603 | if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName; |
| 601 | 604 | gg.zBranch = fossil_strdup(zRefName); |
| 602 | 605 | gg.fromLoaded = 0; |
| 603 | 606 | }else |
| 604 | 607 | if( strncmp(zLine, "tag ", 4)==0 ){ |
| 605 | 608 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -569,10 +569,11 @@ | |
| 569 | gg.xFinish(); |
| 570 | gg.xFinish = finish_blob; |
| 571 | }else |
| 572 | if( strncmp(zLine, "commit ", 7)==0 ){ |
| 573 | const char *zRefName; |
| 574 | gg.xFinish(); |
| 575 | gg.xFinish = finish_commit; |
| 576 | trim_newline(&zLine[7]); |
| 577 | zRefName = &zLine[7]; |
| 578 | |
| @@ -592,13 +593,15 @@ | |
| 592 | ** last commit that holds that tag. |
| 593 | ** |
| 594 | ** None of the above is explained in the git-fast-export |
| 595 | ** documentation. We had to figure it out via trial and error. |
| 596 | */ |
| 597 | for(i=5; i<(int)strlen(zRefName) && zRefName[i]!='/'; i++){} |
| 598 | gg.tagCommit = strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */ |
| 599 | if( zRefName[i+1]!=0 ) zRefName += i+1; |
| 600 | if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName; |
| 601 | gg.zBranch = fossil_strdup(zRefName); |
| 602 | gg.fromLoaded = 0; |
| 603 | }else |
| 604 | if( strncmp(zLine, "tag ", 4)==0 ){ |
| 605 |
| --- src/import.c | |
| +++ src/import.c | |
| @@ -569,10 +569,11 @@ | |
| 569 | gg.xFinish(); |
| 570 | gg.xFinish = finish_blob; |
| 571 | }else |
| 572 | if( strncmp(zLine, "commit ", 7)==0 ){ |
| 573 | const char *zRefName; |
| 574 | int nRef; |
| 575 | gg.xFinish(); |
| 576 | gg.xFinish = finish_commit; |
| 577 | trim_newline(&zLine[7]); |
| 578 | zRefName = &zLine[7]; |
| 579 | |
| @@ -592,13 +593,15 @@ | |
| 593 | ** last commit that holds that tag. |
| 594 | ** |
| 595 | ** None of the above is explained in the git-fast-export |
| 596 | ** documentation. We had to figure it out via trial and error. |
| 597 | */ |
| 598 | nRef = (int)strlen(zRefName); |
| 599 | for(i=5; i<nRef && zRefName[i]!='/'; i++){} |
| 600 | gg.tagCommit = nRef>=9 |
| 601 | && strncmp(&zRefName[5], "tags", 4)==0; /* pattern B */ |
| 602 | if( i<nRef && zRefName[i+1]!=0 ) zRefName += i+1; |
| 603 | if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName; |
| 604 | gg.zBranch = fossil_strdup(zRefName); |
| 605 | gg.fromLoaded = 0; |
| 606 | }else |
| 607 | if( strncmp(zLine, "tag ", 4)==0 ){ |
| 608 |