Fossil SCM

Fix multiple problems with check-in [9360b66a67086d64] that can lead to crashes in Fossil itself, and in git-fast-import, when attempt to export Fossil itself to Git.

drh 2021-01-06 15:38 trunk
Commit b001a1c3def573886d579138a11fdd1c0310ad71cc924ddc113f721086c03d59
1 file changed +17 -8
+17 -8
--- src/export.c
+++ src/export.c
@@ -1170,34 +1170,43 @@
11701170
fprintf(xCmd, "mark %s\n", zMark);
11711171
fossil_free(zMark);
11721172
sqlite3_snprintf(sizeof(buf), buf, "%lld",
11731173
(sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
11741174
);
1175
+
11751176
/*
11761177
** Check for 'fx_' table from previous Git import, otherwise take contact info
11771178
** from user table for <emailaddr> in committer field. If no emailaddr, check
11781179
** if username is in email form, otherwise use generic '[email protected]'.
11791180
*/
1180
- char *zTmp;
11811181
if (db_table_exists("repository", "fx_git")) {
11821182
zEmail = db_text(0, "SELECT email FROM fx_git WHERE user=%Q", pMan->zUser);
11831183
} else {
11841184
zEmail = db_text(0, "SELECT info FROM user WHERE login=%Q", pMan->zUser);
11851185
}
1186
+
11861187
/* Some repo 'info' fields return an empty string hence the second check */
1187
- if (zEmail == NULL || zEmail[0] == '\0') {
1188
+ if( zEmail==0 ){
11881189
/* If username is in emailaddr form, don't append '@noemail.net' */
1189
- if (strchr(pMan->zUser, '@') == NULL) {
1190
+ if( pMan->zUser==0 || strchr(pMan->zUser, '@')==0 ){
11901191
zEmail = mprintf("%[email protected]", pMan->zUser);
11911192
} else {
11921193
zEmail = fossil_strdup(pMan->zUser);
11931194
}
1194
- } else if ((zTmp = strchr(zEmail, '<')) != NULL) {
1195
- ++zTmp;
1196
- char *zTmpEnd = strchr(zTmp, '>');
1197
- *(zTmpEnd) = '\0';
1198
- zEmail = fossil_strdup(zTmp);
1195
+ }else{
1196
+ char *zTmp = strchr(zEmail, '<');
1197
+ if( zTmp ){
1198
+ char *zTmpEnd = strchr(zTmp+1, '>');
1199
+ char *zNew;
1200
+ int i;
1201
+ if( zTmpEnd ) *(zTmpEnd) = 0;
1202
+ zNew = fossil_strdup(zTmp+1);
1203
+ fossil_free(zEmail);
1204
+ zEmail = zNew;
1205
+ for(i=0; zEmail[i] && !fossil_isspace(zEmail[i]); i++){}
1206
+ zEmail[i] = 0;
1207
+ }
11991208
}
12001209
fprintf(xCmd, "# rid=%d\n", rid);
12011210
fprintf(xCmd, "committer %s <%s> %s +0000\n", pMan->zUser, zEmail, buf);
12021211
fossil_free(zEmail);
12031212
blob_init(&comment, pMan->zComment, -1);
12041213
--- src/export.c
+++ src/export.c
@@ -1170,34 +1170,43 @@
1170 fprintf(xCmd, "mark %s\n", zMark);
1171 fossil_free(zMark);
1172 sqlite3_snprintf(sizeof(buf), buf, "%lld",
1173 (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
1174 );
 
1175 /*
1176 ** Check for 'fx_' table from previous Git import, otherwise take contact info
1177 ** from user table for <emailaddr> in committer field. If no emailaddr, check
1178 ** if username is in email form, otherwise use generic '[email protected]'.
1179 */
1180 char *zTmp;
1181 if (db_table_exists("repository", "fx_git")) {
1182 zEmail = db_text(0, "SELECT email FROM fx_git WHERE user=%Q", pMan->zUser);
1183 } else {
1184 zEmail = db_text(0, "SELECT info FROM user WHERE login=%Q", pMan->zUser);
1185 }
 
1186 /* Some repo 'info' fields return an empty string hence the second check */
1187 if (zEmail == NULL || zEmail[0] == '\0') {
1188 /* If username is in emailaddr form, don't append '@noemail.net' */
1189 if (strchr(pMan->zUser, '@') == NULL) {
1190 zEmail = mprintf("%[email protected]", pMan->zUser);
1191 } else {
1192 zEmail = fossil_strdup(pMan->zUser);
1193 }
1194 } else if ((zTmp = strchr(zEmail, '<')) != NULL) {
1195 ++zTmp;
1196 char *zTmpEnd = strchr(zTmp, '>');
1197 *(zTmpEnd) = '\0';
1198 zEmail = fossil_strdup(zTmp);
 
 
 
 
 
 
 
 
1199 }
1200 fprintf(xCmd, "# rid=%d\n", rid);
1201 fprintf(xCmd, "committer %s <%s> %s +0000\n", pMan->zUser, zEmail, buf);
1202 fossil_free(zEmail);
1203 blob_init(&comment, pMan->zComment, -1);
1204
--- src/export.c
+++ src/export.c
@@ -1170,34 +1170,43 @@
1170 fprintf(xCmd, "mark %s\n", zMark);
1171 fossil_free(zMark);
1172 sqlite3_snprintf(sizeof(buf), buf, "%lld",
1173 (sqlite3_int64)((pMan->rDate-2440587.5)*86400.0)
1174 );
1175
1176 /*
1177 ** Check for 'fx_' table from previous Git import, otherwise take contact info
1178 ** from user table for <emailaddr> in committer field. If no emailaddr, check
1179 ** if username is in email form, otherwise use generic '[email protected]'.
1180 */
 
1181 if (db_table_exists("repository", "fx_git")) {
1182 zEmail = db_text(0, "SELECT email FROM fx_git WHERE user=%Q", pMan->zUser);
1183 } else {
1184 zEmail = db_text(0, "SELECT info FROM user WHERE login=%Q", pMan->zUser);
1185 }
1186
1187 /* Some repo 'info' fields return an empty string hence the second check */
1188 if( zEmail==0 ){
1189 /* If username is in emailaddr form, don't append '@noemail.net' */
1190 if( pMan->zUser==0 || strchr(pMan->zUser, '@')==0 ){
1191 zEmail = mprintf("%[email protected]", pMan->zUser);
1192 } else {
1193 zEmail = fossil_strdup(pMan->zUser);
1194 }
1195 }else{
1196 char *zTmp = strchr(zEmail, '<');
1197 if( zTmp ){
1198 char *zTmpEnd = strchr(zTmp+1, '>');
1199 char *zNew;
1200 int i;
1201 if( zTmpEnd ) *(zTmpEnd) = 0;
1202 zNew = fossil_strdup(zTmp+1);
1203 fossil_free(zEmail);
1204 zEmail = zNew;
1205 for(i=0; zEmail[i] && !fossil_isspace(zEmail[i]); i++){}
1206 zEmail[i] = 0;
1207 }
1208 }
1209 fprintf(xCmd, "# rid=%d\n", rid);
1210 fprintf(xCmd, "committer %s <%s> %s +0000\n", pMan->zUser, zEmail, buf);
1211 fossil_free(zEmail);
1212 blob_init(&comment, pMan->zComment, -1);
1213

Keyboard Shortcuts

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