Skip to content

Commit

Permalink
libsysutils: Add boundary check to dispatchCommand
Browse files Browse the repository at this point in the history
Make sure we don't accept more commands than we can chew, to avoid
allocation "problems"

Change-Id: I2490320365110461c12c56532cef50b1dd55e53e
  • Loading branch information
rmcc committed Nov 10, 2011
1 parent a6ae86a commit 9eac435
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libsysutils/src/FrameworkListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) {
}

*q = *p++;
if (!quote && *q == ' ') {
if (!quote && *q == ' ' && argc<FrameworkListener::CMD_ARGS_MAX) {
*q = '\0';
argv[argc++] = strdup(tmp);
memset(tmp, 0, sizeof(tmp));
Expand All @@ -111,6 +111,9 @@ void FrameworkListener::dispatchCommand(SocketClient *cli, char *data) {
q++;
}

if (argc >= FrameworkListener::CMD_ARGS_MAX)
goto out;

argv[argc++] = strdup(tmp);
#if 0
for (k = 0; k < argc; k++) {
Expand Down

0 comments on commit 9eac435

Please sign in to comment.