Fix socket mark parsing.
1. The mark is unsigned. Treat it as such.
2. Allow marks to be input in hex (and octal), not just decimal.
Change-Id: I8710abb1d79530e1bf5972ec42bd05bfd30a085d
diff --git a/ping_common.c b/ping_common.c
index d58d3c4..cc9342d 100644
--- a/ping_common.c
+++ b/ping_common.c
@@ -5,7 +5,7 @@
int options;
-int mark;
+__u32 mark;
int sndbuf;
int ttl;
int rtt;
@@ -294,9 +294,9 @@
case 'm':
{
char *endp;
- mark = (int)strtoul(optarg, &endp, 10);
- if (mark < 0 || *endp != '\0') {
- fprintf(stderr, "mark cannot be negative\n");
+ mark = strtoul(optarg, &endp, 0);
+ if (*endp != '\0') {
+ fprintf(stderr, "ping: invalid mark %s\n", optarg);
exit(2);
}
options |= F_MARK;