We already assume that cmd is NULL terminated, so lets remove the unused
cmd_len. Add check to verify that the received command is NULL
terminated.
Change-Id: I1da3cdf8005b778d7e3e37fe7b2e3ca4b9322801
Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
#define CLIENT_ERR(f, fmt...) \
{ if (f) { fprintf(f, fmt); fprintf(f, "\n"); } ALOGE(fmt); }
#define CLIENT_ERR(f, fmt...) \
{ if (f) { fprintf(f, fmt); fprintf(f, "\n"); } ALOGE(fmt); }
-static int dispatch_cmd(char *cmd, int cmd_len, FILE *f)
+static int dispatch_cmd(char *cmd, FILE *f)
{
char *argv[16], *tmp;
int argc = 0, handle;
{
char *argv[16], *tmp;
int argc = 0, handle;
- err = dispatch_cmd(data_buff, err, f);
+ if (data_buff[err - 1] != 0) {
+ ALOGE("command is not NULL terminated\n");
+ break;
+ }
+
+ err = dispatch_cmd(data_buff, f);
if (err < 0) {
ALOGE("error dispatching command: %d", err);
break;
if (err < 0) {
ALOGE("error dispatching command: %d", err);
break;