Clean up and expand comments.
authorGuy Harris <guy@alum.mit.edu>
Wed, 25 Oct 2017 19:36:02 +0000 (12:36 -0700)
committerGuy Harris <guy@alum.mit.edu>
Wed, 25 Oct 2017 19:36:34 +0000 (19:36 +0000)
Note the dropping of support for hex IPv4 addresses and addresses with
fewer than four components, and indicate that, if there are any places
where that support is expected, we should change those places (i.e.,
don't just change get_host_ipaddr() and, if there aren't any such
places, just leave everything as it is).

It's not clear that get_host_ipaddr() is "Used more in the dfilter
parser rather than in packet dissectors"; that may depend on whether
you're counting number of calls executed from those places or the number
of lines of code making those calls.  Just drop the claim, which is
absent in the comment for get_host_ipaddr6().

Also ask whether we're using get_host_ipaddr{6}() in any places where it
should *only* support numeric addresses rather than names.

Change-Id: Ib5d8730ca703339342f308081a68309479f842c5
Reviewed-on: https://code.wireshark.org/review/24055
Reviewed-by: Guy Harris <guy@alum.mit.edu>
epan/addr_resolv.c

index c9ecd0d78a6d74dc7e4a5b21d8dd522da3d2a6b3..b49dc7831114cd02632e605d2a8c5e9993e8ae40 100644 (file)
@@ -3114,10 +3114,9 @@ c_ares_ghi_cb(void *arg, int status, int timeouts _U_, struct hostent *hp) {
 }
 #endif /* HAVE_C_ARES */
 
-/* Translate a string, assumed either to be a dotted-quad IP address or
- * a host name, to a numeric IP address.  Return TRUE if we succeed and
- * set "*addrp" to that numeric IP address; return FALSE if we fail.
- * Used more in the dfilter parser rather than in packet dissectors */
+/* Translate a string, assumed either to be a dotted-quad IPv4 address or
+ * a host name, to a numeric IPv4 address.  Return TRUE if we succeed and
+ * set "*addrp" to that numeric IPv4 address; return FALSE if we fail. */
 gboolean
 get_host_ipaddr(const char *host, guint32 *addrp)
 {
@@ -3129,6 +3128,16 @@ get_host_ipaddr(const char *host, guint32 *addrp)
     async_hostent_t ahe;
 #endif
 
+    /*
+     * XXX - if there are any places where this needs to support
+     * the hex-address form for IPv4 addresses, or to support
+     * fewer than 4 components for a network address, add that
+     * wherever it's appropriate.
+     *
+     * XXX - are there places where this is used to translate something
+     * that's *only* supposed to be an IPv4 address, and where it
+     * *shouldn't* translate host names?
+     */
     if (!ws_inet_pton4(host, &ipaddr)) {
 
         /* It's not a valid dotted-quad IP address; is it a valid
@@ -3184,8 +3193,8 @@ get_host_ipaddr(const char *host, guint32 *addrp)
 }
 
 /*
- * Translate IPv6 numeric address or FQDN hostname, into binary IPv6 address.
- * Return TRUE if we succeed and set "*addrp" to that numeric IP address;
+ * Translate IPv6 numeric address or FQDN hostname into binary IPv6 address.
+ * Return TRUE if we succeed and set "*addrp" to that numeric IPv6 address;
  * return FALSE if we fail.
  */
 gboolean
@@ -3203,6 +3212,10 @@ get_host_ipaddr6(const char *host, struct e_in6_addr *addrp)
 
     /* It's not a valid dotted-quad IP address; is it a valid
      * host name?
+     *
+     * XXX - are there places where this is used to translate something
+     * that's *only* supposed to be an IPv6 address, and where it
+     * *shouldn't* translate host names?
      */
 
     /* If we're not allowed to do name resolution, don't do name