]> granicus.if.org Git - psmisc/commitdiff
pstree: minor snprintf fix
authorCraig Small <csmall@dropbear.xyz>
Mon, 2 Mar 2020 11:00:25 +0000 (22:00 +1100)
committerCraig Small <csmall@dropbear.xyz>
Mon, 2 Mar 2020 11:00:25 +0000 (22:00 +1100)
The referenced commit used size_t as a return value for
snprintf.

Coverity found the negative check against size_t but the real
problem was using size_t in the first place as an error
returned by snprintf would never be detected.

References:
 commit 5e510d1c9ed8cb61f9c504076a7c4828624b8b07
 Coverity #288526

src/pstree.c

index c4485396abe42cf3fe8411810ae06c2ca78abb29..da02564a0774195582924d276879ad097a226d3e 100644 (file)
@@ -935,8 +935,7 @@ static char* get_threadname(const pid_t pid, const int tid, const char *comm)
     FILE *file;
     char *thread_comm, *endcomm, *threadname;
     char *path = NULL;
-    size_t len = 0;
-    int nbytes;
+    int len, nbytes;
     char readbuf[BUFSIZ + 1];
 
     if (! (threadname = malloc(COMM_LEN + 2 + 1))) {