Fossil SCM

Fix bugs that can cause a segfault if a blank check-in comment is entered.

drh 2007-08-30 18:05 trunk
Commit 1871a93dd4908cb547189d8c6cda978a82bfcdb6
2 files changed +3 +5 -3
--- src/checkin.c
+++ src/checkin.c
@@ -392,10 +392,13 @@
392392
}
393393
db_finalize(&q);
394394
395395
/* Create the manifest */
396396
blob_zero(&manifest);
397
+ if( blob_size(&comment)==0 ){
398
+ blob_append(&comment, "(no comment)", -1);
399
+ }
397400
blob_appendf(&manifest, "C %F\n", blob_str(&comment));
398401
zDate = db_text(0, "SELECT datetime('now')");
399402
zDate[10] = 'T';
400403
blob_appendf(&manifest, "D %s\n", zDate);
401404
db_prepare(&q,
402405
--- src/checkin.c
+++ src/checkin.c
@@ -392,10 +392,13 @@
392 }
393 db_finalize(&q);
394
395 /* Create the manifest */
396 blob_zero(&manifest);
 
 
 
397 blob_appendf(&manifest, "C %F\n", blob_str(&comment));
398 zDate = db_text(0, "SELECT datetime('now')");
399 zDate[10] = 'T';
400 blob_appendf(&manifest, "D %s\n", zDate);
401 db_prepare(&q,
402
--- src/checkin.c
+++ src/checkin.c
@@ -392,10 +392,13 @@
392 }
393 db_finalize(&q);
394
395 /* Create the manifest */
396 blob_zero(&manifest);
397 if( blob_size(&comment)==0 ){
398 blob_append(&comment, "(no comment)", -1);
399 }
400 blob_appendf(&manifest, "C %F\n", blob_str(&comment));
401 zDate = db_text(0, "SELECT datetime('now')");
402 zDate[10] = 'T';
403 blob_appendf(&manifest, "D %s\n", zDate);
404 db_prepare(&q,
405
+5 -3
--- src/vfile.c
+++ src/vfile.c
@@ -384,15 +384,18 @@
384384
int i, fid;
385385
Blob file, mfile;
386386
Manifest m;
387387
char zBuf[100];
388388
389
+ blob_zero(pOut);
390
+ if( pManOut ){
391
+ blob_zero(pManOut);
392
+ }
389393
db_must_be_within_tree();
390394
content_get(vid, &mfile);
391395
if( manifest_parse(&m, &mfile)==0 ){
392
- blob_zero(pOut);
393
- return;
396
+ fossil_panic("manifest file (%d) is malformed", vid);
394397
}
395398
for(i=0; i<m.nFile; i++){
396399
fid = uuid_to_rid(m.aFile[i].zUuid, 0);
397400
md5sum_step_text(m.aFile[i].zName, -1);
398401
content_get(fid, &file);
@@ -400,11 +403,10 @@
400403
md5sum_step_text(zBuf, -1);
401404
md5sum_step_blob(&file);
402405
blob_reset(&file);
403406
}
404407
if( pManOut ){
405
- blob_zero(pManOut);
406408
blob_append(pManOut, m.zRepoCksum, -1);
407409
}
408410
manifest_clear(&m);
409411
md5sum_finish(pOut);
410412
}
411413
--- src/vfile.c
+++ src/vfile.c
@@ -384,15 +384,18 @@
384 int i, fid;
385 Blob file, mfile;
386 Manifest m;
387 char zBuf[100];
388
 
 
 
 
389 db_must_be_within_tree();
390 content_get(vid, &mfile);
391 if( manifest_parse(&m, &mfile)==0 ){
392 blob_zero(pOut);
393 return;
394 }
395 for(i=0; i<m.nFile; i++){
396 fid = uuid_to_rid(m.aFile[i].zUuid, 0);
397 md5sum_step_text(m.aFile[i].zName, -1);
398 content_get(fid, &file);
@@ -400,11 +403,10 @@
400 md5sum_step_text(zBuf, -1);
401 md5sum_step_blob(&file);
402 blob_reset(&file);
403 }
404 if( pManOut ){
405 blob_zero(pManOut);
406 blob_append(pManOut, m.zRepoCksum, -1);
407 }
408 manifest_clear(&m);
409 md5sum_finish(pOut);
410 }
411
--- src/vfile.c
+++ src/vfile.c
@@ -384,15 +384,18 @@
384 int i, fid;
385 Blob file, mfile;
386 Manifest m;
387 char zBuf[100];
388
389 blob_zero(pOut);
390 if( pManOut ){
391 blob_zero(pManOut);
392 }
393 db_must_be_within_tree();
394 content_get(vid, &mfile);
395 if( manifest_parse(&m, &mfile)==0 ){
396 fossil_panic("manifest file (%d) is malformed", vid);
 
397 }
398 for(i=0; i<m.nFile; i++){
399 fid = uuid_to_rid(m.aFile[i].zUuid, 0);
400 md5sum_step_text(m.aFile[i].zName, -1);
401 content_get(fid, &file);
@@ -400,11 +403,10 @@
403 md5sum_step_text(zBuf, -1);
404 md5sum_step_blob(&file);
405 blob_reset(&file);
406 }
407 if( pManOut ){
 
408 blob_append(pManOut, m.zRepoCksum, -1);
409 }
410 manifest_clear(&m);
411 md5sum_finish(pOut);
412 }
413

Keyboard Shortcuts

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