Skip to content

Commit 60237c7

Browse files
committed
DHCP: Use more nd_print_invalid()
Remove "ERROR: " in the error messages. Use instead nd_print_invalid(). Update some error messages.
1 parent 95c9f8f commit 60237c7

File tree

1 file changed

+27
-13
lines changed

1 file changed

+27
-13
lines changed

print-bootp.c

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,8 @@ rfc1048_print(netdissect_options *ndo,
737737
{
738738
/* this option should be 1 byte long */
739739
if (len != 1) {
740-
ND_PRINT("[ERROR: length != 1 byte]");
740+
ND_PRINT("[length != 1 byte]");
741+
nd_print_invalid(ndo);
741742
bp += len;
742743
len = 0;
743744
break;
@@ -787,7 +788,8 @@ rfc1048_print(netdissect_options *ndo,
787788
case TAG_NETBIOS_NODE:
788789
/* this option should be at least 1 byte long */
789790
if (len < 1) {
790-
ND_PRINT("[ERROR: length < 1 byte]");
791+
ND_PRINT("[length < 1 byte]");
792+
nd_print_invalid(ndo);
791793
break;
792794
}
793795
tag = GET_U_1(bp);
@@ -799,7 +801,8 @@ rfc1048_print(netdissect_options *ndo,
799801
case TAG_OPT_OVERLOAD:
800802
/* this option should be at least 1 byte long */
801803
if (len < 1) {
802-
ND_PRINT("[ERROR: length < 1 byte]");
804+
ND_PRINT("[length < 1 byte]");
805+
nd_print_invalid(ndo);
803806
break;
804807
}
805808
tag = GET_U_1(bp);
@@ -811,14 +814,16 @@ rfc1048_print(netdissect_options *ndo,
811814
case TAG_CLIENT_FQDN:
812815
/* this option should be at least 3 bytes long */
813816
if (len < 3) {
814-
ND_PRINT("[ERROR: length < 3 bytes]");
817+
ND_PRINT("[length < 3 bytes]");
818+
nd_print_invalid(ndo);
815819
bp += len;
816820
len = 0;
817821
break;
818822
}
819823
if (GET_U_1(bp) & 0xf0) {
820-
ND_PRINT("[ERROR: MBZ nibble 0x%x != 0] ",
824+
ND_PRINT("[MBZ nibble 0x%x != 0] ",
821825
(GET_U_1(bp) & 0xf0) >> 4);
826+
nd_print_invalid(ndo);
822827
}
823828
if (GET_U_1(bp) & 0x0f)
824829
ND_PRINT("[%s] ",
@@ -841,7 +846,8 @@ rfc1048_print(netdissect_options *ndo,
841846

842847
/* this option should be at least 1 byte long */
843848
if (len < 1) {
844-
ND_PRINT("[ERROR: length < 1 byte]");
849+
ND_PRINT("[length < 1 byte]");
850+
nd_print_invalid(ndo);
845851
break;
846852
}
847853
type = GET_U_1(bp);
@@ -911,7 +917,8 @@ rfc1048_print(netdissect_options *ndo,
911917

912918
/* this option should be at least 5 bytes long */
913919
if (len < 5) {
914-
ND_PRINT("[ERROR: length < 5 bytes]");
920+
ND_PRINT("[length < 5 bytes]");
921+
nd_print_invalid(ndo);
915922
bp += len;
916923
len = 0;
917924
break;
@@ -924,15 +931,17 @@ rfc1048_print(netdissect_options *ndo,
924931
len--;
925932
/* mask_width <= 32 */
926933
if (mask_width > 32) {
927-
ND_PRINT("[ERROR: Mask width (%u) > 32]", mask_width);
934+
ND_PRINT("[Mask width (%u) > 32]", mask_width);
935+
nd_print_invalid(ndo);
928936
bp += len;
929937
len = 0;
930938
break;
931939
}
932940
significant_octets = (mask_width + 7) / 8;
933941
/* significant octets + router(4) */
934942
if (len < significant_octets + 4) {
935-
ND_PRINT("[ERROR: Remaining length (%u) < %u bytes]", len, significant_octets + 4);
943+
ND_PRINT("[Remaining length (%u) < %u bytes]", len, significant_octets + 4);
944+
nd_print_invalid(ndo);
936945
bp += len;
937946
len = 0;
938947
break;
@@ -966,7 +975,8 @@ rfc1048_print(netdissect_options *ndo,
966975

967976
first = 1;
968977
if (len < 2) {
969-
ND_PRINT("[ERROR: length < 2 bytes]");
978+
ND_PRINT("[length < 2 bytes]");
979+
nd_print_invalid(ndo);
970980
bp += len;
971981
len = 0;
972982
break;
@@ -978,13 +988,16 @@ rfc1048_print(netdissect_options *ndo,
978988
ND_PRINT("\n\t ");
979989
ND_PRINT("instance#%u: ", suboptnumber);
980990
if (suboptlen == 0) {
981-
ND_PRINT("[ERROR: suboption length must be non-zero]");
991+
ND_PRINT("[suboption length == 0]");
992+
nd_print_invalid(ndo);
982993
bp += len;
983994
len = 0;
984995
break;
985996
}
986997
if (len < suboptlen) {
987-
ND_PRINT("[ERROR: invalid option]");
998+
ND_PRINT("[length %u < suboption length %u",
999+
len, suboptlen);
1000+
nd_print_invalid(ndo);
9881001
bp += len;
9891002
len = 0;
9901003
break;
@@ -1031,7 +1044,8 @@ rfc1048_print(netdissect_options *ndo,
10311044
bp += suboptlen2;
10321045
}
10331046
if (len != 0) {
1034-
ND_PRINT("[ERROR: length < 2 bytes]");
1047+
ND_PRINT("[length < 2 bytes]");
1048+
nd_print_invalid(ndo);
10351049
}
10361050
break;
10371051

0 commit comments

Comments
 (0)