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.

dmestas 2026-11-20 20:32 UTC small-fixes
Commit 3e2c8b93cdcb55e0ded42245488e2cd1777d16bc24d4f521b846bd758ab5a745
1 file changed +6 -3
+6 -3
--- src/import.c
+++ src/import.c
@@ -569,10 +569,11 @@
569569
gg.xFinish();
570570
gg.xFinish = finish_blob;
571571
}else
572572
if( strncmp(zLine, "commit ", 7)==0 ){
573573
const char *zRefName;
574
+ int nRef;
574575
gg.xFinish();
575576
gg.xFinish = finish_commit;
576577
trim_newline(&zLine[7]);
577578
zRefName = &zLine[7];
578579
@@ -592,13 +593,15 @@
592593
** last commit that holds that tag.
593594
**
594595
** None of the above is explained in the git-fast-export
595596
** documentation. We had to figure it out via trial and error.
596597
*/
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;
600603
if( fossil_strcmp(zRefName, "master")==0 ) zRefName = ggit.zMasterName;
601604
gg.zBranch = fossil_strdup(zRefName);
602605
gg.fromLoaded = 0;
603606
}else
604607
if( strncmp(zLine, "tag ", 4)==0 ){
605608
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button