chiark / gitweb /
bus: fix assert() on HELLO error-path
[elogind.git] / src / nss-resolve / nss-resolve.c
index bc55acf8ddcad0f3c5bd2185131dcb0e6b742c9b..3f32ed06507df81eb72a7aa0c975b27cf5cba52e 100644 (file)
@@ -33,7 +33,7 @@
 
 #include "sd-bus.h"
 #include "bus-util.h"
-#include "bus-errors.h"
+#include "bus-common-errors.h"
 #include "macro.h"
 #include "nss-util.h"
 #include "util.h"
@@ -404,10 +404,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
         alen = FAMILY_ADDRESS_SIZE(af);
         l = strlen(canonical);
 
-        ms = ALIGN(l+1) +
-                sizeof(char*) +
-                (c > 0 ? c : 1) * ALIGN(alen) +
-                (c > 0 ? c+1 : 2) * sizeof(char*);
+        ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
 
         if (buflen < ms) {
                 *errnop = ENOMEM;
@@ -466,11 +463,6 @@ enum nss_status _nss_resolve_gethostbyname3_r(
                         goto fail;
                 }
 
-                if (ifindex < 0) {
-                        r = -EINVAL;
-                        goto fail;
-                }
-
                 memcpy(r_addr + i*ALIGN(alen), a, alen);
                 i++;
         }