- case OACK:
- p = (const u_char *)tp->th_stuff;
- ND_PRINT((ndo, " "));
- /* Print filename or first option */
- if (opcode != OACK)
- ND_PRINT((ndo, "\""));
- i = fn_print(ndo, p, ndo->ndo_snapend);
- if (opcode != OACK)
- ND_PRINT((ndo, "\""));
-
- /* Print the mode (RRQ and WRQ only) and any options */
- while ((p = (const u_char *)strchr((const char *)p, '\0')) != NULL) {
- if (length <= (u_int)(p - (const u_char *)&tp->th_block))
- break;
- p++;
- if (*p != '\0') {
- ND_PRINT((ndo, " "));
- fn_print(ndo, p, ndo->ndo_snapend);
- }
+ if (length == 0)
+ goto trunc;
+ ND_PRINT(" ");
+ /* Print filename */
+ ND_PRINT("\"");
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
+ ND_PRINT("\"");
+ if (ui == 0)
+ goto trunc;
+ bp += ui;
+ length -= ui;
+
+ /* Print the mode - RRQ and WRQ only */
+ if (length == 0)
+ goto trunc; /* no mode */
+ ND_PRINT(" ");
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
+ if (ui == 0)
+ goto trunc;
+ bp += ui;
+ length -= ui;
+
+ /* Print options, if any */
+ while (length != 0) {
+ if (GET_U_1(bp) != '\0')
+ ND_PRINT(" ");
+ ui = nd_printztn(ndo, bp, length, ndo->ndo_snapend);
+ if (ui == 0)
+ goto trunc;
+ bp += ui;
+ length -= ui;