]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Expand a comment.
authorGuy Harris <[email protected]>
Thu, 21 Jun 2018 22:01:34 +0000 (15:01 -0700)
committerGuy Harris <[email protected]>
Thu, 21 Jun 2018 22:01:34 +0000 (15:01 -0700)
util-print.c

index 84c10107451489e82ff43820c1a93ad945eb213e..7cc1d9258c454e20519d411822dddd8a815d611c 100644 (file)
@@ -129,10 +129,21 @@ nd_print(netdissect_options *ndo,
 
 /*
  * Print out a null-terminated filename (or other ASCII string) from
- * a fixed-length buffer, part of the packet buffer.
- * If ep is NULL, assume no truncation check is needed.
+ * a fixed-length field in the packet buffer, or from what remains of
+ * the packet.
+ *
+ * n is the length of the fixed-length field, or the number of bytes
+ * remaining in the packet based on its on-the-network length.
+ *
+ * If ep is non-null, it should point just past the last captured byte
+ * of the packet, e.g. ndo->ndo_snapend.  If ep is NULL, we assume no
+ * truncation check, other than the checks of the field length/remaining
+ * packet data length, is needed.
+ *
  * Return the number of bytes of string processed, including the
- * terminating null, if not truncated.  Return 0 if truncated.
+ * terminating null, if not truncated; as the terminating null is
+ * included in the count, and as there must be a terminating null,
+ * this will always be non-zero.  Return 0 if truncated.
  */
 u_int
 nd_printztn(netdissect_options *ndo,
@@ -146,7 +157,8 @@ nd_printztn(netdissect_options *ndo,
                if (n == 0 || (ep != NULL && s >= ep)) {
                        /*
                         * Truncated.  This includes "no null before we
-                        * got to the end of the fixed-length buffer".
+                        * got to the end of the fixed-length buffer or
+                        * the end of the packet".
                         *
                         * XXX - BOOTP says "null-terminated", which
                         * means the maximum length of the string, in