[AGENT++] R: R: R: pure virtual method called

Jochen Katz katz at agentpp.com
Tue Feb 22 21:21:18 CET 2011


Hi,


> I've tried the patch,
> ...
> This if evaluates to false, therefore h_addr_list is validated. However, the memcpy still crashes.

it seems that you have a strange gethostbyname function and it seems
that it is not possible to get the IP for a hostname on your system.

The patch below will check for the return values.

Regards,
  Jochen


--- address.cpp (Revision 1971)
+++ address.cpp (Arbeitskopie)
@@ -821,7 +821,14 @@
 #if defined(__sun) || defined (__QNX_NEUTRINO)
     lookupResult = gethostbyname_r(inaddr, &lookup_buf, buf, 2048,
&herrno);
 #else
-    gethostbyname_r(inaddr, &lookup_buf, buf, 2048, &lookupResult,
&herrno);
+    int tmp_ret = gethostbyname_r(inaddr, &lookup_buf, buf, 2048,
+                                 &lookupResult, &herrno);
+    if (tmp_ret)
+    {
+      debugprintf(1, "Error (%d, errno %d) from gethostbyname_r",
+                 tmp_ret, herrno);
+      lookupResult = 0;
+    }
 #endif
 #ifdef SNMP_PP_IPv6
     if (!lookupResult)
@@ -830,8 +837,14 @@
       lookupResult = gethostbyname_r(inaddr, AF_INET6, &lookup_buf,
buf, 2048,
                                      &lookupResult, &herrno);
 #else
-      gethostbyname2_r(inaddr, AF_INET6, &lookup_buf, buf, 2048,
-                        &lookupResult, &herrno);
+      int tmp_ret2 = gethostbyname2_r(inaddr, AF_INET6, &lookup_buf, buf,
+                                     2048, &lookupResult, &herrno);
+      if (tmp_ret2)
+      {
+        debugprintf(1, "Error (%d, errno %d) from gethostbyname2_r",
+                   tmp_ret2, herrno);
+        lookupResult = 0;
+      }
 #endif
     }
 #endif // SNMP_PP_IPv6



More information about the AGENTPP mailing list