summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Falgueras García <carlosfg@riseup.net>2016-06-08 11:17:57 +0200
committerPablo Neira Ayuso <pablo@netfilter.org>2016-06-08 13:54:47 +0200
commit610b1208a4d87b874e55982d44c0a9a1a1b7b00d (patch)
tree790bb8a38e06adc11d565176f243a032ba11aea8
parent1891e0e2cefced50e7bfdacd50942cefe5bf73ba (diff)
nlmsg: Improve payload printing
It makes more sense to use isprint() than isalnum() because we use non alphanumeric characters like '%', '_', etc. And, in case of non printable character, print a space is preferable to print a NULL (0) in order to keep alignment. Before: ... |00012|--|00002| |len |flags| type| | 5f 5f 73 65 | | data | s e | 74 25 64 00 | | data | t d ... After: ... |00012|--|00002| |len |flags| type| | 5f 5f 73 65 | | data | _ _ s e | 74 25 64 00 | | data | t % d ... Signed-off-by: Carlos Falgueras García <carlosfg@riseup.net> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r--src/nlmsg.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nlmsg.c b/src/nlmsg.c
index fd2f698..5dfbd88 100644
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -317,10 +317,10 @@ mnl_nlmsg_fprintf_payload(FILE *fd, const struct nlmsghdr *nlh,
0xff & b[i+2], 0xff & b[i+3]);
fprintf(fd, "| data |");
fprintf(fd, "\t %c %c %c %c\n",
- isalnum(b[i]) ? b[i] : 0,
- isalnum(b[i+1]) ? b[i+1] : 0,
- isalnum(b[i+2]) ? b[i+2] : 0,
- isalnum(b[i+3]) ? b[i+3] : 0);
+ isprint(b[i]) ? b[i] : ' ',
+ isprint(b[i+1]) ? b[i+1] : ' ',
+ isprint(b[i+2]) ? b[i+2] : ' ',
+ isprint(b[i+3]) ? b[i+3] : ' ');
}
}
fprintf(fd, "----------------\t------------------\n");