Browse Source

Closed memory leak with Rock Ridge character set conversion failure.

Coverity CID 12562.
release-1.5.4.branch
Thomas Schmitt 6 years ago
parent
commit
d04f438ba1
  1. 28
      libisofs/rockridge.c
  2. 3
      libisofs/rockridge.h

28
libisofs/rockridge.c

@ -383,9 +383,7 @@ int iso_get_rr_name(IsoWriteOpts *opts, char *input_charset,
iso_msg_submit(imgid, ISO_FILENAME_WRONG_CHARSET, ret,
"Charset conversion error. Cannot convert %s from %s to %s",
str, input_charset, output_charset);
/* use the original name, it's the best we can do */
ret = iso_clone_mem(str, name, 0);
*name = NULL;
return ISO_FILENAME_WRONG_CHARSET;
}
@ -1179,9 +1177,12 @@ int susp_calc_nm_sl_al(Ecma119Image *t, Ecma119Node *n, size_t space,
}
}
namelen = 0;
name = get_rr_fname(t, n->node->name);
namelen = strlen(name);
free(name);
if (name != NULL) {
namelen = strlen(name);
free(name);
}
if (flag & 1) {
/* Account for 28 bytes of CE field */
@ -1741,9 +1742,12 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
uint8_t **comps= NULL; /* components of the SL field */
size_t n_comp = 0; /* number of components */
namelen = 0;
name = get_rr_fname(t, n->node->name);
namelen = strlen(name);
if (name != NULL) {
namelen = strlen(name);
free(name);
}
sua_free = space - info->suf_len;
/* Try whether NM, SL, AL will fit into SUA */
@ -1787,6 +1791,13 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
int cew = (nm_type == 1); /* are we writing to CE? */
dest = get_rr_fname(t, ((IsoSymlink*)n->node)->dest);
if (dest == NULL)
dest = strdup("");
if (dest == NULL) {
ret = ISO_OUT_OF_MEM;
goto add_susp_cleanup;
}
prev = dest;
cur = strchr(prev, '/');
while (1) {
@ -2123,7 +2134,8 @@ int rrip_get_susp_fields(Ecma119Image *t, Ecma119Node *n, int type,
add_susp_cleanup: ;
free(name);
free(dest);
if (dest != NULL)
free(dest);
susp_info_free(info);
return ret;
}

3
libisofs/rockridge.h

@ -361,8 +361,7 @@ int read_zisofs_ZF(struct susp_sys_user_entry *zf, uint8_t algorithm[2],
uint32_t *uncompressed_size, int flag);
/**
* Convert a RR filename to the requested charset. On any conversion error,
* the original name will be used.
* Convert a RR filename to the requested charset.
* @param flag bit0= do not issue error messages
*/
int iso_get_rr_name(IsoWriteOpts *opts, char *input_charset,

Loading…
Cancel
Save