Fossil SCM

Avoid NULL pointer deference in the "hook test" command when an invalid hook number is supplied.

drh 2021-03-07 21:21 trunk
Commit 9527034f49dd42a808c78ba75da8556123e6d11977e877da0caac5529107a802
1 file changed +2
+2
--- src/hook.c
+++ src/hook.c
@@ -104,10 +104,11 @@
104104
const char *zAuxFilename /* Name of auxiliary information file */
105105
){
106106
Blob r;
107107
int i;
108108
blob_init(&r, 0, 0);
109
+ if( zCmd==0 ) return 0;
109110
while( zCmd[0] ){
110111
for(i=0; zCmd[i] && zCmd[i]!='%'; i++){}
111112
blob_append(&r, zCmd, i);
112113
if( zCmd[i]==0 ) break;
113114
if( zCmd[i+1]=='F' ){
@@ -403,10 +404,11 @@
403404
while( db_step(&q)==SQLITE_ROW ){
404405
const char *zCmd = db_column_text(&q,0);
405406
char *zCmd2 = hook_subst(zCmd, zAuxFilename);
406407
int needOut = db_column_int(&q,1);
407408
Blob out;
409
+ if( zCmd2==0 ) continue;
408410
blob_init(&out,0,0);
409411
if( needOut ) hook_changes(&out, zOrigRcvid, zNewRcvid);
410412
if( bDryRun ){
411413
fossil_print("%s\n", zCmd2);
412414
if( needOut ){
413415
--- src/hook.c
+++ src/hook.c
@@ -104,10 +104,11 @@
104 const char *zAuxFilename /* Name of auxiliary information file */
105 ){
106 Blob r;
107 int i;
108 blob_init(&r, 0, 0);
 
109 while( zCmd[0] ){
110 for(i=0; zCmd[i] && zCmd[i]!='%'; i++){}
111 blob_append(&r, zCmd, i);
112 if( zCmd[i]==0 ) break;
113 if( zCmd[i+1]=='F' ){
@@ -403,10 +404,11 @@
403 while( db_step(&q)==SQLITE_ROW ){
404 const char *zCmd = db_column_text(&q,0);
405 char *zCmd2 = hook_subst(zCmd, zAuxFilename);
406 int needOut = db_column_int(&q,1);
407 Blob out;
 
408 blob_init(&out,0,0);
409 if( needOut ) hook_changes(&out, zOrigRcvid, zNewRcvid);
410 if( bDryRun ){
411 fossil_print("%s\n", zCmd2);
412 if( needOut ){
413
--- src/hook.c
+++ src/hook.c
@@ -104,10 +104,11 @@
104 const char *zAuxFilename /* Name of auxiliary information file */
105 ){
106 Blob r;
107 int i;
108 blob_init(&r, 0, 0);
109 if( zCmd==0 ) return 0;
110 while( zCmd[0] ){
111 for(i=0; zCmd[i] && zCmd[i]!='%'; i++){}
112 blob_append(&r, zCmd, i);
113 if( zCmd[i]==0 ) break;
114 if( zCmd[i+1]=='F' ){
@@ -403,10 +404,11 @@
404 while( db_step(&q)==SQLITE_ROW ){
405 const char *zCmd = db_column_text(&q,0);
406 char *zCmd2 = hook_subst(zCmd, zAuxFilename);
407 int needOut = db_column_int(&q,1);
408 Blob out;
409 if( zCmd2==0 ) continue;
410 blob_init(&out,0,0);
411 if( needOut ) hook_changes(&out, zOrigRcvid, zNewRcvid);
412 if( bDryRun ){
413 fossil_print("%s\n", zCmd2);
414 if( needOut ){
415

Keyboard Shortcuts

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