0090-pmap: Fix output format of VmFlags.

In the headers, the space was misplaced; for example, "pmap -XX $$"
outputs "VmFlagsMapping" (without a space). Use justify_print() instead
of printf().

There was also an extra space in the output, because vmflags[] (from the
"VmFlags:" line) always ends with a space. Overwriting this last space
with a null byte fixes this misalignment.

Signed-off-by: Craig Small <csmall@enc.com.au>
This commit is contained in:
Qualys Security Advisory 1970-01-01 00:00:00 +00:00 committed by Craig Small
parent 7e2bd279ed
commit 2119cd3dd5

6
pmap.c
View File

@ -397,9 +397,11 @@ loop_end:
/* === GET VMFLAGS === */
nfields = ret ? sscanf(mapbuf, "VmFlags: %"VMFL"[a-z ]", vmflags) : 0;
if (nfields == 1) {
int len = strlen(vmflags);
if (len > 0 && vmflags[len-1] == ' ') vmflags[--len] = '\0';
if (len > maxwv) maxwv = len;
if (! has_vmflags) has_vmflags = 1;
ret = fgets(mapbuf, sizeof mapbuf, f);
if (strlen(vmflags) > maxwv) maxwv = strlen(vmflags);
}
if (firstmapping == 2) { /* width measurement stage, do not print anything yet */
@ -442,7 +444,7 @@ loop_end:
justify_print(listnode->description, listnode->max_width, 1);
if (has_vmflags && is_enabled("VmFlags"))
printf(" %*s", maxwv, "VmFlags ");
maxwv = justify_print("VmFlags", maxwv, 1);
if (is_enabled(nls_Mapping))
justify_print(nls_Mapping, 0, 0);