]> git.proxmox.com Git - mirror_lxcfs.git/commitdiff
bindings: even more concise must_strcat_pid
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Fri, 5 Feb 2016 11:10:15 +0000 (12:10 +0100)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 8 Feb 2016 17:14:55 +0000 (09:14 -0800)
We already assume tmp[] is big enough when using an unsized
sprintf(), considering it contains a single pid number and
is 30 bytes we can assume it was also big enough to hold the
terminating null byte.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
bindings.c

index 5394b44aa21cb2687fde41b3769207e98bd94d94..6e6be6eb3c09ba4fd87298fa32c3ad18202c433c 100644 (file)
@@ -1052,9 +1052,8 @@ static void must_strcat_pid(char **src, size_t *sz, size_t *asz, pid_t pid)
                *src = tmp;
                *asz += BUF_RESERVE_SIZE;
        }
-       memcpy((*src) +*sz , tmp, tmplen);
+       memcpy((*src) +*sz , tmp, tmplen+1); /* include the \0 */
        *sz += tmplen;
-       (*src)[*sz] = '\0';
 }
 
 /*