From: Qualys Security Advisory Date: Thu, 1 Jan 1970 00:00:00 +0000 (+0000) Subject: 0040-proc/devname.c: Never write more than "chop" (part 2). X-Git-Tag: v4.0.0~603 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=69b67b6f6e80993ae0361cd5fdeeb499e8db81eb;p=procps-ng 0040-proc/devname.c: Never write more than "chop" (part 2). "chop" is the maximum offset where the null-byte should be written; respect this even if about to write just one (non-null) character. --- diff --git a/proc/devname.c b/proc/devname.c index 010ea826..b8110c7c 100644 --- a/proc/devname.c +++ b/proc/devname.c @@ -340,7 +340,7 @@ unsigned dev_to_tty(char *restrict ret, unsigned chop, dev_t dev_t_dev, int pid, if( link_name(tmp, MAJOR_OF(dev), MINOR_OF(dev), pid, "fd/255")) goto abbrev; // fall through if unable to find a device file no_tty: - strcpy(ret, "?"); + strcpy(ret, chop >= 1 ? "?" : ""); return 1; abbrev: if((flags&ABBREV_DEV) && !strncmp(tmp,"/dev/",5) && tmp[5]) tmp += 5;