[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pdns: FTBFS on hurd-i386 (for review)



On Wed, 2014-06-25 at 13:10 +0200, Samuel Thibault wrote:
> Svante Signell, le Wed 25 Jun 2014 13:01:49 +0200, a écrit :
> > @@ -483,7 +484,9 @@ bool ArgvMap::file(const char *fname, bo
> >           if (ent->d_name[0] == '.') continue; // skip any dots
> >           if (boost::ends_with(ent->d_name, ".conf")) {
> >              // ensure it's readable file
> > -            snprintf(namebuf, sizeof namebuf, "%s/%s", params["include-dir"].c_str(), ent->d_name);
> > +            len = st.st_size + 1 + strlen(ent->d_name) + 1;
> 
> Err, did you have a look at what st.st_size was?  For a directory,
> it'll be the size of the directory listing in bytes, which
> is completely unrelated to the path. Why not simply using
> params["include-dir"].length() ?

Didn't know about that one, not so fluent in C++.

> > +            namebuf = (char*)malloc(len);
> 
> This will allocate a buffer on each while loop...
> 
> > +            snprintf(namebuf, len, "%s/%s", params["include-dir"].c_str(), ent->d_name);
> >              if (stat(namebuf, &st) || !S_ISREG(st.st_mode)) {
> >                  L << Logger::Error << namebuf << " is not a file" << std::endl;
> >                  throw ArgException(std::string(namebuf) + " does not exist!");
> > @@ -498,6 +501,7 @@ bool ArgvMap::file(const char *fname, bo
> >                  throw ArgException(fn + " could not be parsed");
> >              }
> >        }
> > +      free(namebuf);
> 
> ... but free only one of them, the latest...

Moved into the loop.

> > --- a/pdns/nameserver.cc	2013-07-05 07:35:05.000000000 +0200
> > +++ b/pdns/nameserver.cc	2014-01-28 13:57:36.000000000 +0100
> > @@ -213,7 +213,11 @@ void UDPNameserver::bindIPv6()
> >      if(IsAnyAddress(locala)) {
> >        int val=1;
> >        setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val));     // linux supports this, so why not - might fail on other systems
> > +#ifdef __GNU__ // Same as IPV6_PKTINFO
> > +      setsockopt(s, IPPROTO_IPV6, IPV6_RXINFO, &val, sizeof(val)); 
> > +#else
> >        setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); 
> > +#endif
> 
> As usual, don't make the code GNU-specific, use #ifndef IPV6_RECVPKTINFO
> instead.

Updated patch attached

Index: pdns-3.3.1/pdns/arguments.cc
===================================================================
--- pdns-3.3.1.orig/pdns/arguments.cc
+++ pdns-3.3.1/pdns/arguments.cc
@@ -459,7 +459,8 @@ bool ArgvMap::file(const char *fname, bo
       struct stat st;
       DIR *dir;
       struct dirent *ent;
-      char namebuf[PATH_MAX] = {0};
+      char *namebuf = NULL;
+      int len;
 
       // stat
       if (stat(params["include-dir"].c_str(), &st)) {
@@ -483,7 +484,9 @@ bool ArgvMap::file(const char *fname, bo
          if (ent->d_name[0] == '.') continue; // skip any dots
          if (boost::ends_with(ent->d_name, ".conf")) {
             // ensure it's readable file
-            snprintf(namebuf, sizeof namebuf, "%s/%s", params["include-dir"].c_str(), ent->d_name);
+            len = params["include-dir"].length() + 1 + strlen(ent->d_name) + 1;
+            namebuf = (char*)malloc(len);
+            snprintf(namebuf, len, "%s/%s", params["include-dir"].c_str(), ent->d_name);
             if (stat(namebuf, &st) || !S_ISREG(st.st_mode)) {
                 L << Logger::Error << namebuf << " is not a file" << std::endl;
                 throw ArgException(std::string(namebuf) + " does not exist!");
@@ -497,6 +500,7 @@ bool ArgvMap::file(const char *fname, bo
                 L << Logger::Error << namebuf << " could not be parsed" << std::endl;
                 throw ArgException(fn + " could not be parsed");
             }
+            free(namebuf);
       }
   }
 
Index: pdns-3.3.1/pdns/nameserver.cc
===================================================================
--- pdns-3.3.1.orig/pdns/nameserver.cc
+++ pdns-3.3.1/pdns/nameserver.cc
@@ -213,7 +213,11 @@ void UDPNameserver::bindIPv6()
     if(IsAnyAddress(locala)) {
       int val=1;
       setsockopt(s, IPPROTO_IP, GEN_IP_PKTINFO, &val, sizeof(val));     // linux supports this, so why not - might fail on other systems
+#ifndef IPV6_RECVPKTINFO // IPV6_RXINFO same as IPV6_PKTINFO on GNU/Hurd
+      setsockopt(s, IPPROTO_IPV6, IPV6_RXINFO, &val, sizeof(val)); 
+#else
       setsockopt(s, IPPROTO_IPV6, IPV6_RECVPKTINFO, &val, sizeof(val)); 
+#endif
       setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));      // if this fails, we report an error in tcpreceiver too
     }
     g_localaddresses.push_back(locala);

Reply to: