471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
|
for(k=0, nLine=1; z[k]; k++) if( z[k]=='\n' ) nLine++;
if( nLine>100000000 ) fossil_fatal("too many command-line arguments");
nArg = g.argc + nLine*2;
newArgv = fossil_malloc( sizeof(char*)*nArg );
for(j=0; j<i; j++) newArgv[j] = g.argv[j];
blob_rewind(&file);
while( (n = blob_line(&file, &line))>0 ){
if( n<1 ){
/* Reminder: corner-case: a line with 1 byte and no newline. */
continue;
}
z = blob_buffer(&line);
if('\n'==z[n-1]){
z[n-1] = 0;
|
|
>
>
>
>
>
>
|
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
|
for(k=0, nLine=1; z[k]; k++) if( z[k]=='\n' ) nLine++;
if( nLine>100000000 ) fossil_fatal("too many command-line arguments");
nArg = g.argc + nLine*2;
newArgv = fossil_malloc( sizeof(char*)*nArg );
for(j=0; j<i; j++) newArgv[j] = g.argv[j];
blob_rewind(&file);
while( nLine-->0 && (n = blob_line(&file, &line))>0 ){
/* Reminder: ^^^ nLine check avoids that embedded NUL bytes in the
** --args file causes nLine to be less than blob_line() will end
** up reporting in that case, which leads to an memory illegal
** write. See forum post
** https://fossil-scm.org/forum/forumpost/7b34eecc1b8c for
** details */
if( n<1 ){
/* Reminder: corner-case: a line with 1 byte and no newline. */
continue;
}
z = blob_buffer(&line);
if('\n'==z[n-1]){
z[n-1] = 0;
|