forked from pool/libcdio
176 lines
5.8 KiB
Diff
176 lines
5.8 KiB
Diff
--- libcdio-0.78.2/lib/iso9660/iso9660_fs.c
|
||
+++ libcdio-0.78.2/lib/iso9660/iso9660_fs.c
|
||
@@ -745,6 +745,11 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||
stat_len = sizeof(iso9660_stat_t)+i_fname+2;
|
||
|
||
p_stat = calloc(1, stat_len);
|
||
+ if (!p_stat)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", stat_len);
|
||
+ return NULL;
|
||
+ }
|
||
p_stat->type = (p_iso9660_dir->file_flags & ISO_DIRECTORY)
|
||
? _STAT_DIR : _STAT_FILE;
|
||
p_stat->lsn = from_733 (p_iso9660_dir->extent);
|
||
@@ -768,6 +773,11 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||
/* realloc gives valgrind errors */
|
||
iso9660_stat_t *p_stat_new =
|
||
calloc(1, sizeof(iso9660_stat_t)+i_rr_fname+2);
|
||
+ if (!p_stat_new)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", sizeof(iso9660_stat_t)+i_rr_fname+2);
|
||
+ return NULL;
|
||
+ }
|
||
memcpy(p_stat_new, p_stat, stat_len);
|
||
free(p_stat);
|
||
p_stat = p_stat_new;
|
||
@@ -782,11 +792,14 @@ _iso9660_dir_to_statbuf (iso9660_dir_t *p_iso9660_dir, bool_3way_t b_xa,
|
||
else if (i_joliet_level) {
|
||
int i_inlen = i_fname;
|
||
cdio_utf8_t *p_psz_out = NULL;
|
||
- cdio_charset_to_utf8(p_iso9660_dir->filename, i_inlen,
|
||
- &p_psz_out, "UCS-2BE");
|
||
-
|
||
- strncpy(p_stat->filename, p_psz_out, i_fname);
|
||
- free(p_psz_out);
|
||
+ if (cdio_charset_to_utf8(p_iso9660_dir->filename, i_inlen,
|
||
+ &p_psz_out, "UCS-2BE")) {
|
||
+ strncpy(p_stat->filename, p_psz_out, i_fname);
|
||
+ free(p_psz_out);
|
||
+ }
|
||
+ else {
|
||
+ return NULL;
|
||
+ }
|
||
}
|
||
#endif /*HAVE_JOLIET*/
|
||
else {
|
||
@@ -957,6 +970,11 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
|
||
{
|
||
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
|
||
p_stat = calloc(1, len);
|
||
+ if (!p_stat)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", len);
|
||
+ return NULL;
|
||
+ }
|
||
memcpy(p_stat, _root, len);
|
||
return p_stat;
|
||
}
|
||
@@ -974,6 +992,11 @@ _fs_stat_traverse (const CdIo_t *p_cdio, const iso9660_stat_t *_root,
|
||
}
|
||
|
||
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
|
||
+ if (!p_stat)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", _root->secsize * ISO_BLOCKSIZE);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
if (cdio_read_data_sectors (p_cdio, _dirbuf, _root->lsn, ISO_BLOCKSIZE,
|
||
_root->secsize))
|
||
@@ -1050,6 +1073,11 @@ _fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
|
||
iso9660_stat_t *p_stat;
|
||
unsigned int len=sizeof(iso9660_stat_t) + strlen(_root->filename)+1;
|
||
p_stat = calloc(1, len);
|
||
+ if (!p_stat)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", len);
|
||
+ return NULL;
|
||
+ }
|
||
memcpy(p_stat, _root, len);
|
||
return p_stat;
|
||
}
|
||
@@ -1067,6 +1095,11 @@ _fs_iso_stat_traverse (iso9660_t *p_iso, const iso9660_stat_t *_root,
|
||
}
|
||
|
||
_dirbuf = calloc(1, _root->secsize * ISO_BLOCKSIZE);
|
||
+ if (!_dirbuf)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", _root->secsize * ISO_BLOCKSIZE);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
ret = iso9660_iso_seek_read (p_iso, _dirbuf, _root->lsn, _root->secsize);
|
||
if (ret!=ISO_BLOCKSIZE*_root->secsize) return NULL;
|
||
@@ -1269,6 +1302,11 @@ iso9660_fs_readdir (CdIo_t *p_cdio, const char psz_path[], bool b_mode2)
|
||
}
|
||
|
||
_dirbuf = calloc(1, p_stat->secsize * ISO_BLOCKSIZE);
|
||
+ if (!_dirbuf)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", p_stat->secsize * ISO_BLOCKSIZE);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
if (cdio_read_data_sectors (p_cdio, _dirbuf, p_stat->lsn,
|
||
ISO_BLOCKSIZE, p_stat->secsize))
|
||
@@ -1335,6 +1373,11 @@ iso9660_ifs_readdir (iso9660_t *p_iso, const char psz_path[])
|
||
}
|
||
|
||
_dirbuf = calloc(1, p_stat->secsize * ISO_BLOCKSIZE);
|
||
+ if (!_dirbuf)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", p_stat->secsize * ISO_BLOCKSIZE);
|
||
+ return NULL;
|
||
+ }
|
||
|
||
ret = iso9660_iso_seek_read (p_iso, _dirbuf, p_stat->lsn, p_stat->secsize);
|
||
if (ret != ISO_BLOCKSIZE*p_stat->secsize) return NULL;
|
||
@@ -1399,6 +1442,11 @@ find_fs_lsn_recurse (CdIo_t *p_cdio, const char psz_path[], lsn_t lsn)
|
||
if (statbuf->lsn == lsn) {
|
||
unsigned int len=sizeof(iso9660_stat_t)+strlen(statbuf->filename)+1;
|
||
iso9660_stat_t *ret_stat = calloc(1, len);
|
||
+ if (!ret_stat)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", len);
|
||
+ return NULL;
|
||
+ }
|
||
memcpy(ret_stat, statbuf, len);
|
||
_cdio_list_free (entlist, true);
|
||
_cdio_list_free (dirlist, true);
|
||
@@ -1453,6 +1501,11 @@ find_ifs_lsn_recurse (iso9660_t *p_iso, const char psz_path[], lsn_t lsn)
|
||
if (statbuf->lsn == lsn) {
|
||
unsigned int len=sizeof(iso9660_stat_t)+strlen(statbuf->filename)+1;
|
||
iso9660_stat_t *ret_stat = calloc(1, len);
|
||
+ if (!ret_stat)
|
||
+ {
|
||
+ cdio_warn("Couldn't calloc(1, %d)", len);
|
||
+ return NULL;
|
||
+ }
|
||
memcpy(ret_stat, statbuf, len);
|
||
_cdio_list_free (entlist, true);
|
||
_cdio_list_free (dirlist, true);
|
||
--- libcdio-0.78.2/lib/driver/utf8.c
|
||
+++ libcdio-0.78.2/lib/driver/utf8.c
|
||
@@ -120,6 +120,11 @@ do_convert(iconv_t cd, char * src, int src_len,
|
||
outbytesleft = alloc_size-1;
|
||
|
||
ret = malloc(alloc_size);
|
||
+ if (ret == NULL)
|
||
+ {
|
||
+ fprintf(stderr, "Can't malloc(%d).\n", alloc_size);
|
||
+ return false;
|
||
+ }
|
||
|
||
inbuf = src;
|
||
outbuf = ret;
|
||
@@ -139,11 +144,17 @@ do_convert(iconv_t cd, char * src, int src_len,
|
||
outbytesleft += BYTES_INCREMENT;
|
||
|
||
ret = realloc(ret, alloc_size);
|
||
+ if (ret == NULL)
|
||
+ {
|
||
+ fprintf(stderr, "Can't realloc(%d).\n", alloc_size);
|
||
+ return false;
|
||
+ }
|
||
outbuf = ret + output_pos;
|
||
break;
|
||
default:
|
||
fprintf(stderr, "Iconv failed: %s\n", strerror(errno));
|
||
- free(ret);
|
||
+ if (ret != NULL)
|
||
+ free(ret);
|
||
return false;
|
||
break;
|
||
}
|