* [PATCH] Temporary patch for arpd
@ 2016-10-11 21:50 Pascal
0 siblings, 0 replies; only message in thread
From: Pascal @ 2016-10-11 21:50 UTC (permalink / raw)
To: netdev
[-- Attachment #1: Type: text/plain, Size: 919 bytes --]
Hello. I found wonderful bug in arpd daemon of iproute2 package.
Somehow arpd is absolute unworkable if run program with -f flag. On my
amd64 server i got "Segmentation fault" regardless -f mac-list.txt file
content.
The source of misc/arpd.c is not hard and i found that cause of
this bug is commit dd50247dba85255538d659551305b4bb75bcae62. I'm not
c++ developer, but i suppose segfault occured because argument of
dbase->put() has non-initialized dbdat.data argument.
Also arpd.c has strange condition "if (do_load || do_list)" that not
allows to run program with -f argument.
I did pull out the hexstring_a2n function from utils.c of previous commit
aeb199d5ce86c6c72decaac333cad5a7d7b38b3a and used it to populate
dbdat.data value after which program works fine.
I hurriedly make the patch that makes program alive. Please inspect
this problem, fix this bug and test program with -f key.
PS: sorry for my english =)
[-- Attachment #2: 0001-Temporary-patch-for-arpd.patch --]
[-- Type: application/octet-stream, Size: 1694 bytes --]
From 433147a7303c418845bdb5668910caababf79453 Mon Sep 17 00:00:00 2001
From: Pascal <pascal@pascalhp•net>
Date: Wed, 12 Oct 2016 03:13:53 +0800
Subject: [PATCH] Temporary patch for arpd
---
misc/arpd.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 42 insertions(+), 2 deletions(-)
diff --git a/misc/arpd.c b/misc/arpd.c
index bfab445..567df5b 100644
--- a/misc/arpd.c
+++ b/misc/arpd.c
@@ -584,6 +584,43 @@ static void send_stats(void)
do_stats = 0;
}
+__u8* hexstring_a2n_old(const char *str, __u8 *buf, int blen)
+{
+ int cnt = 0;
+
+ for (;;) {
+ unsigned acc;
+ char ch;
+
+ acc = 0;
+
+ while ((ch = *str) != ':' && ch != 0) {
+ if (ch >= '0' && ch <= '9')
+ ch -= '0';
+ else if (ch >= 'a' && ch <= 'f')
+ ch -= 'a'-10;
+ else if (ch >= 'A' && ch <= 'F')
+ ch -= 'A'-10;
+ else
+ return NULL;
+ acc = (acc<<4) + ch;
+ str++;
+ }
+
+ if (acc > 255)
+ return NULL;
+ if (cnt < blen) {
+ buf[cnt] = acc;
+ cnt++;
+ }
+ if (ch == 0)
+ break;
+ ++str;
+ }
+ if (cnt < blen)
+ memset(buf+cnt, 0, blen-cnt);
+ return buf;
+}
int main(int argc, char **argv)
{
@@ -715,8 +752,11 @@ int main(int argc, char **argv)
goto do_abort;
}
- if (ll_addr_a2n((char *) b1, 6, macbuf) != 6)
+ dbdat.data = hexstring_a2n_old(macbuf, b1, 6);
+ if (dbdat.data == NULL) {
+ fprintf(stderr, "Invalid MAC address: \"%s\"\n", macbuf);
goto do_abort;
+ }
dbdat.size = 6;
if (dbase->put(dbase, &dbkey, &dbdat, 0)) {
@@ -754,7 +794,7 @@ int main(int argc, char **argv)
}
}
- if (do_load || do_list)
+ if (do_list)
goto out;
pset[0].fd = socket(PF_PACKET, SOCK_DGRAM, 0);
--
2.7.0.windows.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-10-11 21:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-11 21:50 [PATCH] Temporary patch for arpd Pascal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox