@@ -3489,10 +3489,15 @@ static int magic_scandesc(cli_ctx *ctx, cli_file_t type)
3489
3489
}
3490
3490
}
3491
3491
3492
- static int cli_base_scandesc (int desc , const char * filepath , cli_ctx * ctx , cli_file_t type )
3492
+ static cl_error_t cli_base_scandesc (int desc , const char * filepath , cli_ctx * ctx , cli_file_t type )
3493
3493
{
3494
3494
STATBUF sb ;
3495
- int ret ;
3495
+ cl_error_t status = CL_CLEAN ;
3496
+ cl_error_t ret = CL_CLEAN ;
3497
+
3498
+ if (!ctx ) {
3499
+ return CL_EARG ;
3500
+ }
3496
3501
3497
3502
const char * parent_filepath = ctx -> sub_filepath ;
3498
3503
ctx -> sub_filepath = filepath ;
@@ -3504,11 +3509,17 @@ static int cli_base_scandesc(int desc, const char *filepath, cli_ctx *ctx, cli_f
3504
3509
cli_dbgmsg ("in cli_magic_scandesc (reclevel: %u/%u)\n" , ctx -> recursion , ctx -> engine -> maxreclevel );
3505
3510
if (FSTAT (desc , & sb ) == -1 ) {
3506
3511
cli_errmsg ("magic_scandesc: Can't fstat descriptor %d\n" , desc );
3507
- early_ret_from_magicscan (CL_ESTAT );
3512
+
3513
+ status = CL_ESTAT ;
3514
+ cli_dbgmsg ("cli_magic_scandesc: returning %d %s (no post, no cache)\n" , status , __AT__ );
3515
+ goto done ;
3508
3516
}
3509
3517
if (sb .st_size <= 5 ) {
3510
3518
cli_dbgmsg ("Small data (%u bytes)\n" , (unsigned int )sb .st_size );
3511
- early_ret_from_magicscan (CL_CLEAN );
3519
+
3520
+ status = CL_CLEAN ;
3521
+ cli_dbgmsg ("cli_magic_scandesc: returning %d %s (no post, no cache)\n" , status , __AT__ );
3522
+ goto done ;
3512
3523
}
3513
3524
3514
3525
ctx -> fmap ++ ;
@@ -3517,18 +3528,22 @@ static int cli_base_scandesc(int desc, const char *filepath, cli_ctx *ctx, cli_f
3517
3528
cli_errmsg ("CRITICAL: fmap() failed\n" );
3518
3529
ctx -> fmap -- ;
3519
3530
perf_stop (ctx , PERFT_MAP );
3520
- early_ret_from_magicscan (CL_EMEM );
3531
+
3532
+ status = CL_EMEM ;
3533
+ cli_dbgmsg ("cli_magic_scandesc: returning %d %s (no post, no cache)\n" , status , __AT__ );
3534
+ goto done ;
3521
3535
}
3522
3536
perf_stop (ctx , PERFT_MAP );
3523
3537
3524
- ret = magic_scandesc (ctx , type );
3538
+ status = magic_scandesc (ctx , type );
3525
3539
3526
3540
funmap (* ctx -> fmap );
3527
3541
ctx -> fmap -- ;
3528
3542
3543
+ done :
3529
3544
ctx -> sub_filepath = parent_filepath ;
3530
3545
3531
- return ret ;
3546
+ return status ;
3532
3547
}
3533
3548
3534
3549
int cli_magic_scandesc (int desc , const char * filepath , cli_ctx * ctx )
0 commit comments