Fossil SCM
Avoid NULL pointer deference in the "hook test" command when an invalid hook number is supplied.
Commit
9527034f49dd42a808c78ba75da8556123e6d11977e877da0caac5529107a802
Parent
c070a27f5dfcb74…
1 file changed
+2
+2
| --- src/hook.c | ||
| +++ src/hook.c | ||
| @@ -104,10 +104,11 @@ | ||
| 104 | 104 | const char *zAuxFilename /* Name of auxiliary information file */ |
| 105 | 105 | ){ |
| 106 | 106 | Blob r; |
| 107 | 107 | int i; |
| 108 | 108 | blob_init(&r, 0, 0); |
| 109 | + if( zCmd==0 ) return 0; | |
| 109 | 110 | while( zCmd[0] ){ |
| 110 | 111 | for(i=0; zCmd[i] && zCmd[i]!='%'; i++){} |
| 111 | 112 | blob_append(&r, zCmd, i); |
| 112 | 113 | if( zCmd[i]==0 ) break; |
| 113 | 114 | if( zCmd[i+1]=='F' ){ |
| @@ -403,10 +404,11 @@ | ||
| 403 | 404 | while( db_step(&q)==SQLITE_ROW ){ |
| 404 | 405 | const char *zCmd = db_column_text(&q,0); |
| 405 | 406 | char *zCmd2 = hook_subst(zCmd, zAuxFilename); |
| 406 | 407 | int needOut = db_column_int(&q,1); |
| 407 | 408 | Blob out; |
| 409 | + if( zCmd2==0 ) continue; | |
| 408 | 410 | blob_init(&out,0,0); |
| 409 | 411 | if( needOut ) hook_changes(&out, zOrigRcvid, zNewRcvid); |
| 410 | 412 | if( bDryRun ){ |
| 411 | 413 | fossil_print("%s\n", zCmd2); |
| 412 | 414 | if( needOut ){ |
| 413 | 415 |
| --- 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 |