From 8ed8777a5bbaefa00656e87b9a3b4a76bbc99fb9 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Tue, 3 May 2011 11:50:43 +0000 Subject: [PATCH] Replaced some large local variables by other means in xorriso/iso_img.c --- libisoburn/trunk/xorriso/iso_img.c | 88 +++++++++++++------- libisoburn/trunk/xorriso/xorriso_timestamp.h | 2 +- 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/libisoburn/trunk/xorriso/iso_img.c b/libisoburn/trunk/xorriso/iso_img.c index 5da8876f..6c4834f1 100644 --- a/libisoburn/trunk/xorriso/iso_img.c +++ b/libisoburn/trunk/xorriso/iso_img.c @@ -345,10 +345,12 @@ int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, char *filter, FILE *fp, int flag) { int is_default, no_defaults, i, is_default_id= 0, ret; - char *line, bspec[SfileadrL + 80], zeros[28]; + char *line, *bspec= NULL, zeros[28]; off_t file_size; struct stat stbuf; + Xorriso_alloc_meM(bspec, char, SfileadrL + 80); + no_defaults= flag & 1; line= xorriso->result_line; @@ -379,7 +381,7 @@ int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, load_size == 2048 && is_default_id && emul == 0) { sprintf(line, "-boot_image isolinux %s\n", bspec); Xorriso_status_result(xorriso,filter,fp,flag&2); - return(1); + {ret= 1; goto ex;}; } file_size= 0; @@ -393,7 +395,7 @@ int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, Text_shellsafe(bin_path, line, 1); strcat(line, "\n"); Xorriso_status_result(xorriso,filter,fp,flag&2); - return(1); + {ret= 1; goto ex;}; } } @@ -451,7 +453,10 @@ int Xorriso_boot_item_status(struct XorrisO *xorriso, char *cat_path, if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); - return(1); + ret= 1; +ex:; + Xorriso_free_meM(bspec); + return(ret); } @@ -524,7 +529,7 @@ int Xorriso_boot_image_status(struct XorrisO *xorriso, char *filter, FILE *fp, { int ret, i, num_boots, hflag; int bin_path_in_use= 0, is_default, no_defaults; - char sfe[5*SfileadrL], path[SfileadrL], *form= "any", *line, *hpt; + char *path= NULL, *form= "any", *line, *hpt; struct burn_drive_info *dinfo; struct burn_drive *drive; IsoImage *image= NULL; @@ -534,6 +539,7 @@ int Xorriso_boot_image_status(struct XorrisO *xorriso, char *filter, FILE *fp, enum eltorito_boot_media_type media_type; unsigned char id_string[29], sel_crit[21]; + Xorriso_alloc_meM(path, char, SfileadrL); line= xorriso->result_line; no_defaults= flag & 1; @@ -573,8 +579,9 @@ no_image:; bin_path_in_use= 1; if(xorriso->boot_image_cat_path[0] && bin_path_in_use) { is_default= 0; - sprintf(line,"-boot_image %s cat_path=%s\n", - form, Text_shellsafe(xorriso->boot_image_cat_path, sfe, 0)); + sprintf(line,"-boot_image %s cat_path=", form); + Text_shellsafe(xorriso->boot_image_cat_path, line, 1); + strcat(line, "\n"); if(!(is_default && no_defaults)) Xorriso_status_result(xorriso,filter,fp,flag&2); } @@ -666,6 +673,7 @@ ex: free(boots); if(bootnodes != NULL) free(bootnodes); + Xorriso_free_meM(path); return(ret); } @@ -694,7 +702,7 @@ int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag) int ret, bin_path_valid= 0,has_isolinux_mbr= 0, i, num_boots; unsigned int mbr_lba= 0; off_t lb0_count; - char *respt, sfe[5*SfileadrL], path[SfileadrL]; + char *respt, *path; unsigned char lb0[2048]; struct burn_drive_info *dinfo; struct burn_drive *drive; @@ -703,6 +711,7 @@ int Xorriso_show_boot_info(struct XorrisO *xorriso, int flag) IsoFile *bootimg_node, **bootnodes = NULL; IsoBoot *bootcat_node; + Xorriso_alloc_meM(path, char, SfileadrL); respt= xorriso->result_line; if(xorriso->boot_count > 0) { @@ -782,20 +791,24 @@ no_boot:; if(flag & 2) {ret= 1; goto ex;} - if(xorriso->loaded_boot_cat_path[0]) - sprintf(respt, "Boot catalog : %s\n", - Text_shellsafe(xorriso->loaded_boot_cat_path, sfe, 0)); - else + if(xorriso->loaded_boot_cat_path[0]) { + sprintf(respt, "Boot catalog : "); + Text_shellsafe(xorriso->loaded_boot_cat_path, respt, 1); + strcat(respt, "\n"); + } else { sprintf(respt, "Boot catalog : -not-found-at-load-time-\n"); + } Xorriso_toc_line(xorriso, flag & 8); - if(bin_path_valid) - sprintf(respt, "Boot image : %s", Text_shellsafe(path, sfe, 0)); - else if(xorriso->loaded_boot_bin_lba <= 0) + if(bin_path_valid) { + sprintf(respt, "Boot image : "); + Text_shellsafe(path, respt, 1); + } else if(xorriso->loaded_boot_bin_lba <= 0) { sprintf(respt, "Boot image : -not-found-at-load-time-"); - else + } else { sprintf(respt, "Boot image : -not-found-any-more-by-lba=%d", xorriso->loaded_boot_bin_lba); + } Xorriso__append_boot_params(respt, bootimg, 0); strcat(respt, "\n"); Xorriso_toc_line(xorriso, flag & 8); @@ -803,9 +816,10 @@ no_boot:; if(num_boots > 1) { for(i= 1; i < num_boots; i++) { ret= Xorriso_path_from_node(xorriso, (IsoNode *) bootnodes[i], path, 0); - if(ret > 0) - sprintf(respt, "Boot image : %s", Text_shellsafe(path, sfe, 0)); - else + if(ret > 0) { + sprintf(respt, "Boot image : "); + Text_shellsafe(path, respt, 1); + } else sprintf(respt, "Boot image : -not-found-any-more-"); Xorriso__append_boot_params(respt, boots[i], 0); strcat(respt, "\n"); @@ -820,6 +834,7 @@ ex:; free(bootnodes); if(image != NULL) iso_image_unref(image); /* release obtained reference */ + Xorriso_free_meM(path); return(ret); } @@ -889,13 +904,17 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, { int ret, lba, track, session, params_flag= 0, is_safe= 0, is_extra_drive= 0; int give_up= 0, mount_chardev= 0, status, aquire_flag= 0; - char volid[33], *devadr, mount_command[SfileadrL], adr_data[163], *adr_pt; - char *dev_path, libburn_adr[BURN_DRIVE_ADR_LEN + SfileadrL]; - char sfe[5 * SfileadrL], *dpt, *sysname= ""; + char volid[33], *devadr, *mount_command= NULL, *adr_data= NULL, *adr_pt; + char *dev_path, *libburn_adr= NULL; + char *dpt, *sysname= ""; struct stat stbuf; struct burn_drive_info *dinfo= NULL; struct burn_drive *drive= NULL; + Xorriso_alloc_meM(mount_command, char, SfileadrL); + Xorriso_alloc_meM(adr_data, char, 163); + Xorriso_alloc_meM(libburn_adr, char, BURN_DRIVE_ADR_LEN + SfileadrL); + devadr= dev; adr_pt= adr_value; if(strcmp(dev, "indev") == 0) { @@ -932,8 +951,8 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, /* do only accept regular files and block devices */ ret= stat(dev_path, &stbuf); if(ret == -1) { - sprintf(xorriso->info_text, "Cannot determine properties of file %s", - Text_shellsafe(dev_path, sfe, 0)); + sprintf(xorriso->info_text, "Cannot determine properties of file "); + Text_shellsafe(dev_path, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); ret= 0; goto ex; } @@ -943,8 +962,8 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, if(!(S_ISREG(stbuf.st_mode) || (S_ISBLK(stbuf.st_mode) && !mount_chardev) || (S_ISCHR(stbuf.st_mode) && !mount_chardev))) { sprintf(xorriso->info_text, - "File object is not suitable as mount device: %s", - Text_shellsafe(dev_path, sfe, 0)); + "File object is not suitable as mount device: "); + Text_shellsafe(dev_path, xorriso->info_text, 1); Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); ret= 0; goto ex; } @@ -1006,8 +1025,9 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, } Xorriso_process_msg_queues(xorriso,0); - sprintf(xorriso->info_text, "Volume id : %s\n", - Text_shellsafe(volid, sfe, 0)); + sprintf(xorriso->info_text, "Volume id : "); + Text_shellsafe(volid, xorriso->info_text, 1); + strcat(xorriso->info_text, "\n"); Xorriso_info(xorriso, 0); if(flag & 1) { sprintf(xorriso->result_line, "%s\n", mount_command); @@ -1030,15 +1050,16 @@ int Xorriso_mount(struct XorrisO *xorriso, char *dev, int adr_mode, Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0); ret= 0; goto ex; } - sprintf(xorriso->info_text, "\nMounted session %d of device %s", - session, Text_shellsafe(dev_path, sfe, 0)); + sprintf(xorriso->info_text, "\nMounted session %d of device ", session); + Text_shellsafe(dev_path, xorriso->info_text, 1); dpt= strchr(cmd, ':'); if(dpt == NULL) dpt= cmd ; else dpt++; - sprintf(xorriso->info_text + strlen(xorriso->info_text), - " as directory %s\n", Text_shellsafe(dpt, sfe, 0)); + sprintf(xorriso->info_text + strlen(xorriso->info_text), " as directory "); + Text_shellsafe(dpt, xorriso->info_text, 1); + strcat(xorriso->info_text, "\n"); Xorriso_info(xorriso, 0); } } @@ -1049,6 +1070,9 @@ ex:; burn_drive_info_free(dinfo); Xorriso_process_msg_queues(xorriso,0); } + Xorriso_free_meM(mount_command); + Xorriso_free_meM(adr_data); + Xorriso_free_meM(libburn_adr); return(ret); } diff --git a/libisoburn/trunk/xorriso/xorriso_timestamp.h b/libisoburn/trunk/xorriso/xorriso_timestamp.h index d2cc9f4a..d8bba158 100644 --- a/libisoburn/trunk/xorriso/xorriso_timestamp.h +++ b/libisoburn/trunk/xorriso/xorriso_timestamp.h @@ -1 +1 @@ -#define Xorriso_timestamP "2011.05.03.100744" +#define Xorriso_timestamP "2011.05.03.115103"