Don't look at string[length - 1] if length == 0.

This commit is contained in:
nicm
2013-10-10 12:27:38 +00:00
parent 282c5f9644
commit b8b85fbb0c
2 changed files with 5 additions and 5 deletions

View File

@@ -575,7 +575,7 @@ client_dispatch_wait(void *data0)
imsg_free(&imsg);
return (-1);
case MSG_SHELL:
if (data[datalen - 1] != '\0')
if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_SHELL string");
clear_signals(0);
@@ -659,7 +659,7 @@ client_dispatch_attached(void)
kill(getpid(), SIGTSTP);
break;
case MSG_LOCK:
if (data[datalen - 1] != '\0')
if (datalen == 0 || data[datalen - 1] != '\0')
fatalx("bad MSG_LOCK string");
system(data);