Commit e73d6e414c703d82e33c18e08ac828279cc4dd2a

Kano 2014-02-27T13:35:56

api - buffer size off by 1 for joined commands

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
diff --git a/api.c b/api.c
index a4234eb..e3dc72d 100644
--- a/api.c
+++ b/api.c
@@ -4690,8 +4690,8 @@ void api(int api_thr_id)
 				if (!did) {
 					if (strchr(cmd, CMDJOIN)) {
 						firstjoin = isjoin = true;
-						// cmd + leading '|' + '\0'
-						cmdsbuf = malloc(strlen(cmd) + 2);
+						// cmd + leading+tailing '|' + '\0'
+						cmdsbuf = malloc(strlen(cmd) + 3);
 						if (!cmdsbuf)
 							quithere(1, "OOM cmdsbuf");
 						strcpy(cmdsbuf, "|");