From 8d03fbcd558dc17d407c8f87a7b44dabc888bf85 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Mon, 2 May 2011 21:12:45 +0000 Subject: [PATCH] Replaced some large local variables by other means in xorriso/drive_mgt.c --- libisoburn/trunk/xorriso/drive_mgt.c | 89 ++++++++++++-------- libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 54 insertions(+), 37 deletions(-) diff --git a/libisoburn/trunk/xorriso/drive_mgt.c b/libisoburn/trunk/xorriso/drive_mgt.c index ac760bca..ced421b7 100644 --- a/libisoburn/trunk/xorriso/drive_mgt.c +++ b/libisoburn/trunk/xorriso/drive_mgt.c @@ -49,9 +49,11 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, int flag) { int ret, is_known_mmc= 0; - char *path_pt, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL]; - char *abs_pt, abs_adr[SfileadrL]; + char *path_pt, *libburn_adr= NULL; + char *abs_pt, *abs_adr= NULL; + Xorriso_alloc_meM(libburn_adr, char, BURN_DRIVE_ADR_LEN + SfileadrL); + Xorriso_alloc_meM(abs_adr, char, SfileadrL); path_pt= adr; if(strncmp(adr, "stdio:", 6) == 0) path_pt= adr + 6; @@ -67,11 +69,11 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, Xorriso_msgs_submit(xorriso, 0, "Relative drive path given. Cannot determine working directory.", errno, "FAILURE", 0); - return(-1); + {ret= -1; goto ex;} } ret= Sfile_add_to_path(abs_adr, path_pt, 0); if(ret <= 0) - return(-1); + {ret= -1; goto ex;} } is_known_mmc= burn_drive_convert_fs_adr(path_pt, libburn_adr); @@ -82,7 +84,7 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, goto ok; ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_blacklist, path_pt, 0); if(ret < 0) - return(ret); + goto ex; if(ret) { strcpy(xorriso->info_text, "Drive address "); Text_shellsafe(adr, xorriso->info_text, 1); @@ -92,15 +94,15 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, ret - 1, 0), xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); - return(0); + {ret= 0; goto ex;} } /* if in greylist and not MMC and not stdio prefix: reject */ if(is_known_mmc < 0) - return(ret); + goto ex; if(adr == path_pt && !is_known_mmc) { /* no prefix, no MMC */ ret= Xorriso_is_in_patternlist(xorriso, xorriso->drive_greylist, path_pt,0); if(ret < 0) - return(ret); + goto ex; if(ret) { strcpy(xorriso->info_text, "Drive address "); Text_shellsafe(adr, xorriso->info_text, 1); @@ -113,30 +115,34 @@ int Xorriso_auto_driveadr(struct XorrisO *xorriso, char *adr, char *result, Xorriso_msgs_submit(xorriso, 0, "If the address is a legitimate target, prepend \"stdio:\"", 0, "HINT", 0); - return(0); + {ret= 0; goto ex;} } } ok:; if(strncmp(adr, "mmc:", 4) == 0) { if(Sfile_str(result, path_pt, 0) <= 0) - return(0); + {ret= 0; goto ex;} } else if(adr == path_pt && is_known_mmc <= 0) { Sfile_str(result, "stdio:", 0); if(Sfile_str(result, adr, 1) <= 0) - return(0); + {ret= 0; goto ex;} } else { if(Sfile_str(result, adr, 0) <= 0) - return(0); + {ret= 0; goto ex;} } if(strncmp(result, "stdio:", 6)==0) { if(xorriso->ban_stdio_write) { strcpy(xorriso->info_text, "Drive address banned by -ban_stdio_write : "); Text_shellsafe(result, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); - return(0); + {ret= 0; goto ex;} } } - return(1); + ret= 1; +ex:; + Xorriso_free_meM(libburn_adr); + Xorriso_free_meM(abs_adr); + return(ret); } @@ -162,27 +168,30 @@ int Xorriso_aquire_drive(struct XorrisO *xorriso, char *adr, int flag) IsoImage *volset = NULL; IsoNode *root_node; struct isoburn_read_opts *ropts= NULL; - char libburn_adr[SfileadrL], *boot_fate, *sev; + char *libburn_adr= NULL, *boot_fate, *sev; size_t value_length; char *value= NULL; double num; - char volid[33], adr_data[163], *adr_pt; + char volid[33], *adr_data, *adr_pt; + + Xorriso_alloc_meM(libburn_adr, char, SfileadrL); + Xorriso_alloc_meM(adr_data, char, 163); if((flag&3)==0) { sprintf(xorriso->info_text, "XORRISOBURN program error : Xorriso_aquire_drive bit0+bit1 not set"); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0); - return(-1); + {ret= -1; goto ex;} } ret= Xorriso_give_up_drive(xorriso, (flag&3)|8); if(ret<=0) - return(ret); + goto ex; if(flag & 1) xorriso->isofs_st_out= time(0) - 1; ret= Xorriso_auto_driveadr(xorriso, adr, libburn_adr, 0); if(ret <= 0) - return(ret); + goto ex; if(strcmp(libburn_adr,"stdio:/dev/fd/1")==0) { if(xorriso->dev_fd_1<0) { sprintf(xorriso->info_text, @@ -529,6 +538,8 @@ ex: } if(ropts!=NULL) isoburn_ropt_destroy(&ropts, 0); + Xorriso_free_meM(libburn_adr); + Xorriso_free_meM(adr_data); return(ret); } @@ -543,13 +554,12 @@ int Xorriso_give_up_drive(struct XorrisO *xorriso, int flag) int in_is_out_too, ret, do_eject; struct burn_drive_info *dinfo; struct burn_drive *drive; - char sfe[5*SfileadrL]; in_is_out_too= (xorriso->in_drive_handle == xorriso->out_drive_handle); if((flag&4) && in_is_out_too && (flag&(1|2))) { if((flag&3)!=3) { - sprintf(xorriso->info_text,"Giving up for -eject whole -dev %s", - Text_shellsafe(xorriso->indev, sfe, 0)); + sprintf(xorriso->info_text,"Giving up for -eject whole -dev "); + Text_shellsafe(xorriso->indev, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); } flag|= 3; /* give up in/out drive to eject it */ @@ -681,28 +691,32 @@ ex:; int Xorriso_reaquire_outdev(struct XorrisO *xorriso, int flag) { int ret, aq_flag; - char drive_name[SfileadrL], sfe[5*SfileadrL]; + char *drive_name= NULL; + Xorriso_alloc_meM(drive_name, char, SfileadrL); aq_flag= flag&3; strcpy(drive_name, xorriso->outdev); Xorriso_give_up_drive(xorriso, aq_flag); if(aq_flag==0) { - sprintf(xorriso->info_text,"Gave up -outdev %s", - Text_shellsafe(xorriso->outdev, sfe, 0)); + sprintf(xorriso->info_text,"Gave up -outdev "); + Text_shellsafe(xorriso->outdev, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); - return(1); + {ret= 1; goto ex;} } - sprintf(xorriso->info_text,"Re-aquiring -outdev %s", - Text_shellsafe(drive_name, sfe, 0)); + sprintf(xorriso->info_text,"Re-aquiring -outdev "); + Text_shellsafe(drive_name, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0); ret= Xorriso_aquire_drive(xorriso, drive_name, aq_flag); if(ret<=0) { - sprintf(xorriso->info_text,"Could not re-aquire -outdev %s", - Text_shellsafe(xorriso->outdev, sfe, 0)); + sprintf(xorriso->info_text,"Could not re-aquire -outdev "); + Text_shellsafe(xorriso->outdev, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); - return(ret); + goto ex; } - return(1); + ret= 1; +ex:; + Xorriso_free_meM(drive_name); + return(ret); } @@ -1681,7 +1695,7 @@ int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist, int start_lba= 0; struct burn_drive *drive; struct burn_drive_info *dinfo; - char data[64*1024], sfe[5*SfileadrL]; + char *data= NULL; off_t data_count, to_read, read_count= 0, write_amount; double pre_read_time, post_read_time, time_diff, total_time_diff= 0; double last_abort_file_time= 0; @@ -1692,6 +1706,8 @@ int Xorriso_check_interval(struct XorrisO *xorriso, struct SpotlisT *spotlist, int tag_type= 0, valid, was_sb_tag= 0, in_track_gap= 0; char *comparison= "", *sev_text= "DEBUG", *tag_type_name= ""; + Xorriso_alloc_meM(data, char, 64*1024); + ret= Xorriso_get_drive_handles(xorriso, &dinfo, &drive, "on attempt to check media readability", 2 * !!job->use_dev); @@ -1966,9 +1982,9 @@ abort_check:; SEEK_SET); if(ret == -1) { failed_to_write:; - sprintf(xorriso->info_text, "Cannot write %d bytes to lba %d of %s", - (int) data_count, i + from_lba, - Text_shellsafe(job->data_to_path, sfe, 0)); + sprintf(xorriso->info_text, "Cannot write %d bytes to lba %d of ", + (int) data_count, i + from_lba); + Text_shellsafe(job->data_to_path, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0); {ret= 0; goto ex;} @@ -2034,6 +2050,7 @@ failed_to_write:; ex: if(ctx != NULL) iso_md5_end(&ctx, md5); + Xorriso_free_meM(data); return(ret); } diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index 6b79a17f..bdae55d8 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2011.05.02.191905" +#define Xorriso_timestamP "2011.05.02.211310"