diff options
author | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-05-22 17:52:30 +0200 |
---|---|---|
committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2017-05-26 17:22:23 +0200 |
commit | c5f119c06dbf56887709912cf247cc7679ffc411 (patch) | |
tree | acf0cf6d58a18de2a2f1c34fe7aabdd3e8b320c4 /isisd | |
parent | Merge pull request #610 from donaldsharp/rpprefixlen (diff) | |
download | frr-c5f119c06dbf56887709912cf247cc7679ffc411.tar.xz frr-c5f119c06dbf56887709912cf247cc7679ffc411.zip |
*: do not take address of packed member
May result in alignment errors on certain platforms
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'isisd')
-rw-r--r-- | isisd/isis_pdu.c | 3 | ||||
-rw-r--r-- | isisd/iso_checksum.c | 11 | ||||
-rw-r--r-- | isisd/iso_checksum.h | 2 |
3 files changed, 7 insertions, 9 deletions
diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index 69beade47..d62682b10 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -1315,7 +1315,8 @@ process_lsp (int level, struct isis_circuit *circuit, const u_char *ssnpa) /* Checksum sanity check - FIXME: move to correct place */ /* 12 = sysid+pdu+remtime */ if (iso_csum_verify (STREAM_PNT (circuit->rcv_stream) + 4, - pdu_len - 12, &hdr->checksum)) + pdu_len - 12, hdr->checksum, + offsetof(struct isis_link_state_hdr, checksum) - 4)) { zlog_debug ("ISIS-Upd (%s): LSP %s invalid LSP checksum 0x%04x", circuit->area->area_tag, diff --git a/isisd/iso_checksum.c b/isisd/iso_checksum.c index d036c0ba7..70b6b91ed 100644 --- a/isisd/iso_checksum.c +++ b/isisd/iso_checksum.c @@ -46,14 +46,14 @@ */ int -iso_csum_verify (u_char * buffer, int len, uint16_t * csum) +iso_csum_verify (u_char * buffer, int len, uint16_t csum, int offset) { u_int16_t checksum; u_int32_t c0; u_int32_t c1; - c0 = *csum & 0xff00; - c1 = *csum & 0x00ff; + c0 = csum & 0xff00; + c1 = csum & 0x00ff; /* * If both are zero return correct @@ -67,11 +67,8 @@ iso_csum_verify (u_char * buffer, int len, uint16_t * csum) if (c0 == 0 || c1 == 0) return 1; - /* Offset of checksum from the start of the buffer */ - int offset = (u_char *) csum - buffer; - checksum = fletcher_checksum(buffer, len, offset); - if (checksum == *csum) + if (checksum == csum) return 0; return 1; } diff --git a/isisd/iso_checksum.h b/isisd/iso_checksum.h index cca6ee24a..50f6a7d56 100644 --- a/isisd/iso_checksum.h +++ b/isisd/iso_checksum.h @@ -23,6 +23,6 @@ #ifndef _ZEBRA_ISO_CSUM_H #define _ZEBRA_ISO_CSUM_H -int iso_csum_verify (u_char * buffer, int len, uint16_t * csum); +int iso_csum_verify (u_char * buffer, int len, uint16_t csum, int offset); #endif /* _ZEBRA_ISO_CSUM_H */ |