Make a few one-byte fetches use GET_U_1().
In ospf_print_tos_metrics() lose an excess ND_TCHECK_SIZE() and make the
function void.
Make ospf_decode_lls() void -- the only case when it returned a non-zero
value was if the LLS block is invalid, and it already signals that with a
message. It is a separate matter if the invalid packet is also truncated,
and since there is no proper check for that, just return without printing
a misleading message.
Switch ospf_print() to nd_trunc_longjmp().
/*
* Print all the per-topology metrics.
*/
/*
* Print all the per-topology metrics.
*/
ospf_print_tos_metrics(netdissect_options *ndo,
const union un_tos *tos)
{
ospf_print_tos_metrics(netdissect_options *ndo,
const union un_tos *tos)
{
* All but the first metric contain a valid topology id.
*/
while (toscount != 0) {
* All but the first metric contain a valid topology id.
*/
while (toscount != 0) {
tos_type = GET_U_1(tos->metrics.tos_type);
ND_PRINT("\n\t\ttopology %s (%u), metric %u",
tok2str(ospf_topology_values, "Unknown",
tos_type = GET_U_1(tos->metrics.tos_type);
ND_PRINT("\n\t\ttopology %s (%u), metric %u",
tok2str(ospf_topology_values, "Unknown",
- return 0;
-trunc:
- return 1;
- if (ospf_print_tos_metrics(ndo, &rlp->un_tos))
- goto trunc;
+ ospf_print_tos_metrics(ndo, &rlp->un_tos);
rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
(GET_U_1(rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
rlp = (const struct rlalink *)((const u_char *)(rlp + 1) +
(GET_U_1(rlp->un_tos.link.link_tos_count) * sizeof(union un_tos)));
ospf_decode_lls(netdissect_options *ndo,
const struct ospfhdr *op, u_int length)
{
ospf_decode_lls(netdissect_options *ndo,
const struct ospfhdr *op, u_int length)
{
case OSPF_TYPE_HELLO:
if (!(GET_U_1(op->ospf_hello.hello_options) & OSPF_OPTION_L))
case OSPF_TYPE_HELLO:
if (!(GET_U_1(op->ospf_hello.hello_options) & OSPF_OPTION_L))
break;
case OSPF_TYPE_DD:
if (!(GET_U_1(op->ospf_db.db_options) & OSPF_OPTION_L))
break;
case OSPF_TYPE_DD:
if (!(GET_U_1(op->ospf_db.db_options) & OSPF_OPTION_L))
}
/* dig deeper if LLS data is available; see RFC4813 */
}
/* dig deeper if LLS data is available; see RFC4813 */
dataend = (const u_char *)op + length;
if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
dataend = (const u_char *)op + length;
if (GET_BE_U_2(op->ospf_authtype) == OSPF_AUTH_MD5) {
- dptr = dptr + op->ospf_authdata[3];
- length2 += op->ospf_authdata[3];
+ dptr = dptr + GET_U_1(op->ospf_authdata + 3);
+ length2 += GET_U_1(op->ospf_authdata + 3);
}
if (length2 >= length) {
ND_PRINT("\n\t[LLS truncated]");
}
if (length2 >= length) {
ND_PRINT("\n\t[LLS truncated]");
}
ND_PRINT("\n\t LLS: checksum: 0x%04x", (u_int) GET_BE_U_2(dptr));
}
ND_PRINT("\n\t LLS: checksum: 0x%04x", (u_int) GET_BE_U_2(dptr));
case OSPF_AUTH_MD5:
ND_PRINT("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
case OSPF_AUTH_MD5:
ND_PRINT("\n\tKey-ID: %u, Auth-Length: %u, Crypto Sequence Number: 0x%08x",
- *((op->ospf_authdata) + 2),
- *((op->ospf_authdata) + 3),
+ GET_U_1(op->ospf_authdata + 2),
+ GET_U_1(op->ospf_authdata + 3),
GET_BE_U_4((op->ospf_authdata) + 4));
break;
GET_BE_U_4((op->ospf_authdata) + 4));
break;
/* ospf version 2 */
if (ospf_decode_v2(ndo, op, dataend))
goto trunc;
/* ospf version 2 */
if (ospf_decode_v2(ndo, op, dataend))
goto trunc;
- if (length > GET_BE_U_2(op->ospf_len)) {
- if (ospf_decode_lls(ndo, op, length))
- goto trunc;
- }
+ if (length > GET_BE_U_2(op->ospf_len))
+ ospf_decode_lls(ndo, op, length);