Made callers of iso_file_source_get_path() aware that NULL might be returned.

This commit is contained in:
Thomas Schmitt 2011-06-01 11:37:30 +02:00
parent e7d9559d16
commit d361186bca
4 changed files with 24 additions and 4 deletions

View File

@ -392,6 +392,8 @@ char* ifs_get_path(IsoFileSource *src)
char *path, *new_path;
int pathlen;
if (data->name == NULL)
return NULL;
path = ifs_get_path(data->parent);
if (path == NULL)
return NULL;

View File

@ -517,6 +517,10 @@ int lfs_get_aa_string(IsoFileSource *src, unsigned char **aa_string, int flag)
to AAIP ACL representation. Clean out st_mode ACL entries.
*/
path = iso_file_source_get_path(src);
if (path == NULL) {
ret = ISO_NULL_POINTER;
goto ex;
}
ret = aaip_get_attr_list(path, &num_attrs, &names,
&value_lengths, &values,
(!(flag & 2)) | 2 | (flag & 4) | 16);

View File

@ -869,6 +869,10 @@ void iso_stream_get_file_name(IsoStream *stream, char *name)
if (!strncmp(type, "fsrc", 4)) {
FSrcStreamData *data = stream->data;
char *path = iso_file_source_get_path(data->src);
if (path == NULL) {
name[0] = 0;
return;
}
strncpy(name, path, PATH_MAX - 1);
name[PATH_MAX - 1] = 0;
free(path);

View File

@ -761,11 +761,16 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
ret = iso_file_source_open(dir);
if (ret < 0) {
char *path = iso_file_source_get_path(dir);
path = iso_file_source_get_path(dir);
/* instead of the probable error, we throw a sorry event */
if (path != NULL) {
ret = iso_msg_submit(image->id, ISO_FILE_CANT_ADD, ret,
"Can't open dir %s", path);
free(path);
} else {
ret = iso_msg_submit(image->id, ISO_NULL_POINTER, ret,
"Can't open dir. NULL pointer caught as dir name");
}
return ret;
}
@ -785,6 +790,11 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
}
path = iso_file_source_get_path(file);
if (path == NULL) {
ret = iso_msg_submit(image->id, ISO_NULL_POINTER, ret,
"NULL pointer caught as file path");
return ret;
}
name = strrchr(path, '/') + 1;
if (image->follow_symlinks) {