Update to call parse_proto_and_port() before allocating a new port list. This

fixes the following stack trace when generating an SPA packet that contains
"none/0" for the port list:

Program received signal SIGABRT, Aborted.
0x00007ffff74574b5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
        in ../nptl/sysdeps/unix/sysv/linux/raise.c
(gdb) where
#0  0x00007ffff74574b5 in *__GI_raise (sig=<value optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff745af50 in *__GI_abort () at abort.c:92
#2  0x00007ffff748fc97 in __libc_message (do_abort=<value optimized out>, fmt=<value optimized out>) at ../sysdeps/unix/sysv/linux/libc_fatal.c:189
#3  0x00007ffff7499dd6 in malloc_printerr (action=3, str=0x7ffff755b748 "double free or corruption (fasttop)", ptr=<value optimized out>) at malloc.c:6217
#4  0x00007ffff749e74c in *__GI___libc_free (mem=<value optimized out>) at malloc.c:3716
#5  0x000000000040570c in free_acc_port_list (acc=0x60a1c0, port_str=0x7fffffffdc20 "none/0") at access.c:390
#6  acc_check_port_access (acc=0x60a1c0, port_str=0x7fffffffdc20 "none/0") at access.c:892
#7  0x0000000000403f4a in incoming_spa (opts=<value optimized out>) at incoming_spa.c:229
#8  0x00000000004041eb in pcap_capture (opts=0x7fffffffde40) at pcap_capture.c:155
#9  0x0000000000402ba7 in main (argc=9, argv=0x7fffffffe6e8) at fwknopd.c:241



git-svn-id: file:///home/mbr/svn/fwknop/trunk@201 510a4753-2344-4c79-9c09-4d669213fbeb
This commit is contained in:
Michael Rash 2010-01-20 01:20:36 +00:00
parent b34c506a90
commit e8b875789b

View File

@ -223,6 +223,12 @@ add_port_list_ent(acc_port_list_t **plist, char *port_str)
acc_port_list_t *last_plist, *new_plist, *tmp_plist; acc_port_list_t *last_plist, *new_plist, *tmp_plist;
/* Parse the string into its components and continue only if there
* are no problems with the incoming string.
*/
if(parse_proto_and_port(port_str, &proto_int, &port) != 0)
return;
if((new_plist = calloc(1, sizeof(acc_port_list_t))) == NULL) if((new_plist = calloc(1, sizeof(acc_port_list_t))) == NULL)
{ {
log_msg(LOG_ERR|LOG_STDERR, log_msg(LOG_ERR|LOG_STDERR,
@ -248,15 +254,6 @@ add_port_list_ent(acc_port_list_t **plist, char *port_str)
last_plist->next = new_plist; last_plist->next = new_plist;
} }
/* Parse the string into its components.
*/
if(parse_proto_and_port(port_str, &proto_int, &port) != 0)
{
free(new_plist);
new_plist = NULL;
return;
}
new_plist->proto = proto_int; new_plist->proto = proto_int;
new_plist->port = port; new_plist->port = port;