diff --git a/lib/iso9660/iso9660.c b/lib/iso9660/iso9660.c index d99f711c..9ab41713 100644 --- a/lib/iso9660/iso9660.c +++ b/lib/iso9660/iso9660.c @@ -1,5 +1,5 @@ /* - $Id: iso9660.c,v 1.4 2005/02/12 18:24:21 rocky Exp $ + $Id: iso9660.c,v 1.5 2005/02/20 17:47:01 rocky Exp $ Copyright (C) 2000 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -44,7 +44,7 @@ const char ISO_STANDARD_ID[] = {'C', 'D', '0', '0', '1'}; #include #endif -static const char _rcsid[] = "$Id: iso9660.c,v 1.4 2005/02/12 18:24:21 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660.c,v 1.5 2005/02/20 17:47:01 rocky Exp $"; /* Variables to hold debugger-helping enumerations */ enum iso_enums1 iso_enums1; @@ -222,7 +222,8 @@ iso9660_name_translate_ext(const char *old, char *new, uint8_t i_joliet_level) { int len = strlen(old); int i; - + + if (0 == len) return 0; for (i = 0; i < len; i++) { unsigned char c = old[i]; if (!c) diff --git a/lib/iso9660/iso9660_fs.c b/lib/iso9660/iso9660_fs.c index 8d1ddb73..247e959b 100644 --- a/lib/iso9660/iso9660_fs.c +++ b/lib/iso9660/iso9660_fs.c @@ -1,5 +1,5 @@ /* - $Id: iso9660_fs.c,v 1.21 2005/02/20 10:21:01 rocky Exp $ + $Id: iso9660_fs.c,v 1.22 2005/02/20 17:47:01 rocky Exp $ Copyright (C) 2001 Herbert Valerio Riedel Copyright (C) 2003, 2004, 2005 Rocky Bernstein @@ -52,7 +52,7 @@ #include -static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.21 2005/02/20 10:21:01 rocky Exp $"; +static const char _rcsid[] = "$Id: iso9660_fs.c,v 1.22 2005/02/20 17:47:01 rocky Exp $"; /* Implementation of iso9660_t type */ struct _iso9660_s { @@ -818,8 +818,14 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa, int i_rr_fname = get_rock_ridge_filename(p_iso9660_dir, rr_fname, p_stat); if (i_rr_fname > 0) { - if (i_rr_fname > i_fname) - realloc(p_stat, sizeof(iso9660_stat_t)+i_rr_fname+2); + if (i_rr_fname > i_fname) { + /* realloc gives valgrind errors */ + iso9660_stat_t *p_stat_new = + calloc(1, sizeof(iso9660_stat_t)+i_rr_fname+2); + memcpy(p_stat_new, p_stat, stat_len); + free(p_stat); + p_stat = p_stat_new; + } strncpy(p_stat->filename, rr_fname, i_rr_fname+1); } else { #ifdef HAVE_JOLIET @@ -1042,18 +1048,22 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root, cmp = strcmp(splitpath[0], p_stat->filename); if ( 0 != cmp && 0 == p_env->i_joliet_level && yep != p_stat->b_rock ) { - char *trans_fname = malloc(strlen(p_stat->filename)); + char *trans_fname = NULL; + unsigned int i_trans_fname=strlen(p_stat->filename); int trans_len; - if (trans_fname == NULL) { - cdio_warn("can't allocate %lu bytes", - (long unsigned int) strlen(p_stat->filename)); - return NULL; + if (i_trans_fname) { + trans_fname = calloc(1, i_trans_fname+1); + if (!trans_fname) { + cdio_warn("can't allocate %lu bytes", + (long unsigned int) strlen(p_stat->filename)); + return NULL; + } + trans_len = iso9660_name_translate_ext(p_stat->filename, trans_fname, + p_env->i_joliet_level); + cmp = strcmp(splitpath[0], trans_fname); + free(trans_fname); } - trans_len = iso9660_name_translate_ext(p_stat->filename, trans_fname, - p_env->i_joliet_level); - cmp = strcmp(splitpath[0], trans_fname); - free(trans_fname); } if (!cmp) { diff --git a/lib/iso9660/rock.c b/lib/iso9660/rock.c index 04b28595..b420140a 100644 --- a/lib/iso9660/rock.c +++ b/lib/iso9660/rock.c @@ -1,5 +1,5 @@ /* - $Id: rock.c,v 1.6 2005/02/20 16:21:06 rocky Exp $ + $Id: rock.c,v 1.7 2005/02/20 17:47:01 rocky Exp $ Copyright (C) 2005 Rocky Bernstein Adapted from GNU/Linux fs/isofs/rock.c (C) 1992, 1993 Eric Youngdale @@ -132,11 +132,11 @@ get_rock_ridge_filename(iso9660_dir_t * p_iso9660_dir, p_stat->b_rock = yep; if (truncate) break; if (rr->u.NM.flags & ISO_ROCK_NM_PARENT) { - i_namelen = strlen(".."); + i_namelen = sizeof(".."); strcat(psz_name, ".."); break; } else if (rr->u.NM.flags & ISO_ROCK_NM_CURRENT) { - i_namelen = strlen("."); + i_namelen = sizeof("."); strcat(psz_name, "."); break; }