[mpd] Fix possible stack buffer overflow in argument parser
This commit is contained in:
parent
ecab3266ce
commit
40c22e3d2f
|
@ -476,14 +476,14 @@ mpd_pars_quoted(char **input)
|
||||||
* @param argv the array containing the found arguments
|
* @param argv the array containing the found arguments
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
mpd_parse_args(char *args, int *argc, char **argv)
|
mpd_parse_args(char *args, int *argc, char **argv, int argvsz)
|
||||||
{
|
{
|
||||||
char *input;
|
char *input;
|
||||||
|
|
||||||
input = args;
|
input = args;
|
||||||
*argc = 0;
|
*argc = 0;
|
||||||
|
|
||||||
while (*input != 0)
|
while (*input != 0 && *argc < argvsz)
|
||||||
{
|
{
|
||||||
// Ignore whitespace characters
|
// Ignore whitespace characters
|
||||||
if (*input == ' ')
|
if (*input == ' ')
|
||||||
|
@ -4368,7 +4368,7 @@ mpd_read_cb(struct bufferevent *bev, void *ctx)
|
||||||
DPRINTF(E_DBG, L_MPD, "MPD message: %s\n", line);
|
DPRINTF(E_DBG, L_MPD, "MPD message: %s\n", line);
|
||||||
|
|
||||||
// Split the read line into command name and arguments
|
// Split the read line into command name and arguments
|
||||||
ret = mpd_parse_args(line, &argc, argv);
|
ret = mpd_parse_args(line, &argc, argv, COMMAND_ARGV_MAX);
|
||||||
if (ret != 0 || argc <= 0)
|
if (ret != 0 || argc <= 0)
|
||||||
{
|
{
|
||||||
// Error handling for argument parsing error
|
// Error handling for argument parsing error
|
||||||
|
|
Loading…
Reference in New Issue