[olsr-dev] patch for nameservice

John Hay (spam-protected)
Fri Apr 20 07:45:16 CEST 2007


On Fri, Apr 20, 2007 at 01:12:26AM +0200, Aaron Kaplan wrote:
> 
> On Apr 19, 2007, at 9:38 PM, John Hay wrote:
> 
> >Any feedback on this one? Is it ok or not? Will it be committed or
> >not? :-)
> >
> John, I have some feedback. The linux man page says that the return  
> value does not have to be "1" in case of success. Just > 0
> 
> maybe we should change that if to "> 0 " ? To make it clean in more  
> OSes.

That is ok with me. I only checked the FreeBSD inet_pton() man page
and RFCs 2553 and 3493. All are very clear that the return value
can only be -1, 0 or 1.

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

> >
> >On Sun, Apr 08, 2007 at 06:32:50AM +0200, John Hay wrote:
> >>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