1
0
mirror of https://gitlab.xiph.org/xiph/ezstream.git synced 2024-11-03 04:17:18 -05:00

Check args prior to allocating resources

This commit is contained in:
Moritz Grimm 2015-06-01 14:57:20 +02:00
parent 9d9bf9865c
commit fb7d3b4e38

View File

@ -364,26 +364,22 @@ metadata_program(const char *program, int normalize)
metadata_t *md;
struct stat st;
md = metadata_create(program);
md->program = 1;
md->string = xstrdup("");
if (stat(program, &st) == -1) {
log_error("%s: %s", program, strerror(errno));
metadata_free(&md);
return (NULL);
}
if (st.st_mode & S_IWOTH) {
log_error("%s: world writeable", program);
metadata_free(&md);
return (NULL);
}
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
log_error("%s: not an executable program", program);
metadata_free(&md);
return (NULL);
}
md = metadata_create(program);
md->program = 1;
md->string = xstrdup("");
md->normalize = normalize;
return (md);