[olsr-dev] patch for nameservice

John Hay (spam-protected)
Sun Apr 8 06:32:50 CEST 2007


Hi,

The first fix a coredump when using the nameservice plugin with a
dns-server entry. As far as I can determine strndup() should not 
convert an empty string to a NULL pointer.

The other patch is just something I noticed. The return value of
inet_pton() can be -1, 0 or 1. Only 1 indicates no error.

These diffs are against 0.5.1pre in the cvs tree.

BTW it would be great if we could standardize on a coding style.
My preference would be the FreeBSD style(9) because I'm used to
it and it is well documented:

http://www.freebsd.org/cgi/man.cgi?query=style&sektion=9

But anything that is documented is ok.

John
-- 
John Hay -- (spam-protected) / (spam-protected)


--- lib/nameservice/src/compat.c.orig	Thu Jun  2 17:34:00 2005
+++ lib/nameservice/src/compat.c	Sat Apr  7 18:15:11 2007
@@ -11,9 +11,6 @@
   size_t len = strlen(ptr);
   char *ret = NULL;
 
-  if(!len)
-    return NULL;
-
   if(len > size)
     len = size;
 

--- lib/nameservice/src/nameservice.c.orig	Wed Feb 21 14:06:34 2007
+++ lib/nameservice/src/nameservice.c	Sun Apr  8 06:10:01 2007
@@ -187,7 +187,7 @@
 		if (strlen(value) == 0) {
             my_forwarders = add_name_to_list(my_forwarders, "", NAME_FORWARDER, NULL);
             olsr_printf(1,"\nNAME PLUGIN: parameter dns-server: (main address)");
-        } else if (inet_pton(olsr_cnf->ip_version, value, &ip)) {
+        } else if (inet_pton(olsr_cnf->ip_version, value, &ip) == 1) {
             my_forwarders = add_name_to_list(my_forwarders, "", NAME_FORWARDER, &ip);
             olsr_printf(1,"\nNAME PLUGIN: parameter dns-server: (%s)", value);
         } else {
@@ -1280,7 +1280,7 @@
     }
     
     //ip in service-line is allowed 
-    if (inet_pton(olsr_cnf->ip_version, hostname_or_ip, &olsr_ip)) {
+    if (inet_pton(olsr_cnf->ip_version, hostname_or_ip, &olsr_ip) == 1) {
         if (allowed_ip(&olsr_ip)) {
             olsr_printf(2, "NAME PLUGIN: ip %s in service %s is OK\n", olsr_ip_to_string(&olsr_ip), service_line);
             free(hostname_or_ip);




More information about the Olsr-dev mailing list