Merge pull request #673 from chme/mpd_segfault

[mpd] Fix segfault
This commit is contained in:
ejurgensen 2019-01-26 16:09:05 +01:00 committed by GitHub
commit fbc2440ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -56,10 +56,10 @@ char *
safe_strdup(const char *str); safe_strdup(const char *str);
char * char *
safe_asprintf(const char *fmt, ...); safe_asprintf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
int int
safe_snprintf_cat(char *dst, size_t n, const char *fmt, ...); safe_snprintf_cat(char *dst, size_t n, const char *fmt, ...) __attribute__ ((format (printf, 3, 4)));
/* Key/value functions */ /* Key/value functions */

View File

@ -2267,7 +2267,7 @@ mpd_command_listplaylist(struct evbuffer *evbuf, int argc, char **argv, char **e
else else
{ {
// Argument is a playlist name, prepend default playlist directory // Argument is a playlist name, prepend default playlist directory
path = safe_asprintf("%s/%s%s", default_pl_dir, argv[1]); path = safe_asprintf("%s/%s", default_pl_dir, argv[1]);
} }
pli = db_pl_fetch_byvirtualpath(path); pli = db_pl_fetch_byvirtualpath(path);
@ -2330,7 +2330,7 @@ mpd_command_listplaylistinfo(struct evbuffer *evbuf, int argc, char **argv, char
else else
{ {
// Argument is a playlist name, prepend default playlist directory // Argument is a playlist name, prepend default playlist directory
path = safe_asprintf("%s/%s%s", default_pl_dir, argv[1]); path = safe_asprintf("%s/%s", default_pl_dir, argv[1]);
} }
pli = db_pl_fetch_byvirtualpath(path); pli = db_pl_fetch_byvirtualpath(path);
@ -2449,7 +2449,7 @@ mpd_command_load(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, s
else else
{ {
// Argument is a playlist name, prepend default playlist directory // Argument is a playlist name, prepend default playlist directory
path = safe_asprintf("%s/%s%s", default_pl_dir, argv[1]); path = safe_asprintf("%s/%s", default_pl_dir, argv[1]);
} }
pli = db_pl_fetch_byvirtualpath(path); pli = db_pl_fetch_byvirtualpath(path);
@ -3260,7 +3260,7 @@ mpd_sticker_set(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, co
rating *= MPD_RATING_FACTOR; rating *= MPD_RATING_FACTOR;
if (rating > DB_FILES_RATING_MAX) if (rating > DB_FILES_RATING_MAX)
{ {
*errmsg = safe_asprintf("rating '%s' is greater than maximum value allowed", argv[5], (DB_FILES_RATING_MAX / MPD_RATING_FACTOR)); *errmsg = safe_asprintf("rating '%s' is greater than maximum value allowed", argv[5]);
return ACK_ERROR_ARG; return ACK_ERROR_ARG;
} }