Browse files

libsysutils: Add boundary check to dispatchCommand

Make sure we don't accept more commands than we can chew, to avoid
allocation "problems"

Change-Id: I2490320365110461c12c56532cef50b1dd55e53e
  • Loading branch information...
1 parent a6ae86a commit 9eac43572e71c6a1b27d4150066bc9a85c731bb6 @rmcc rmcc committed Nov 10, 2011
Showing with 4 additions and 1 deletion.
  1. +4 −1 libsysutils/src/FrameworkListener.cpp
View
5 libsysutils/src/FrameworkListener.cpp
@@ -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));
@@ -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++) {

0 comments on commit 9eac435

Please sign in to comment.