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:
parent
9d9bf9865c
commit
fb7d3b4e38
@ -364,26 +364,22 @@ metadata_program(const char *program, int normalize)
|
|||||||
metadata_t *md;
|
metadata_t *md;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
md = metadata_create(program);
|
|
||||||
md->program = 1;
|
|
||||||
md->string = xstrdup("");
|
|
||||||
|
|
||||||
if (stat(program, &st) == -1) {
|
if (stat(program, &st) == -1) {
|
||||||
log_error("%s: %s", program, strerror(errno));
|
log_error("%s: %s", program, strerror(errno));
|
||||||
metadata_free(&md);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (st.st_mode & S_IWOTH) {
|
if (st.st_mode & S_IWOTH) {
|
||||||
log_error("%s: world writeable", program);
|
log_error("%s: world writeable", program);
|
||||||
metadata_free(&md);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
if (!(st.st_mode & (S_IEXEC | S_IXGRP | S_IXOTH))) {
|
||||||
log_error("%s: not an executable program", program);
|
log_error("%s: not an executable program", program);
|
||||||
metadata_free(&md);
|
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
md = metadata_create(program);
|
||||||
|
md->program = 1;
|
||||||
|
md->string = xstrdup("");
|
||||||
md->normalize = normalize;
|
md->normalize = normalize;
|
||||||
|
|
||||||
return (md);
|
return (md);
|
||||||
|
Loading…
Reference in New Issue
Block a user