]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use EXTRACT_16BITS to extract big-endian 16-bit quantities from the packet.
authorGuy Harris <[email protected]>
Wed, 27 Jan 2010 02:35:53 +0000 (18:35 -0800)
committerGuy Harris <[email protected]>
Wed, 27 Jan 2010 02:35:53 +0000 (18:35 -0800)
There's no guarantee that those quantities will be properly aligned, nor
is there any guarantee that fetching an improperly-aligned quantity will
work as desired.

print-sctp.c

index c0fa3087bd0ef0a6ed038f547ed5a68b045b435d..0229396de66d9244bb91e50b243b299690933c0d 100644 (file)
@@ -232,16 +232,16 @@ void sctp_print(const u_char *bp,        /* beginning of sctp packet */
                u_int chunksize = sizeof(struct sctpDataPart)+
                                  sizeof(struct sctpChunkDesc);
                payloadPtr = (const u_char *) (dataHdrPtr + 1);
-               if (htons(chunkDescPtr->chunkLength) <
+               if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
                        sizeof(struct sctpDataPart)+
                        sizeof(struct sctpChunkDesc)+1) {
                /* Less than 1 byte of chunk payload */
                        printf("bogus ForCES chunk length %u]",
-                       htons(chunkDescPtr->chunkLength));
+                           EXTRACT_16BITS(&chunkDescPtr->chunkLength));
                        return;
                }
 
-               forces_print(payloadPtr, htons(chunkDescPtr->chunkLength)- chunksize);
+               forces_print(payloadPtr, EXTRACT_16BITS(&chunkDescPtr->chunkLength)- chunksize);
           } else if (vflag >= 2) {     /* if verbose output is specified */
                                        /* at the command line */
                const u_char *payloadPtr;
@@ -251,16 +251,16 @@ void sctp_print(const u_char *bp,        /* beginning of sctp packet */
                if (!suppress_default_print) {
                        payloadPtr = (const u_char *) (++dataHdrPtr);
                        printf(":");
-                       if (htons(chunkDescPtr->chunkLength) <
+                       if (EXTRACT_16BITS(&chunkDescPtr->chunkLength) <
                            sizeof(struct sctpDataPart)+
                            sizeof(struct sctpChunkDesc)+1) {
                                /* Less than 1 byte of chunk payload */
                                printf("bogus chunk length %u]",
-                                   htons(chunkDescPtr->chunkLength));
+                                   EXTRACT_16BITS(&chunkDescPtr->chunkLength));
                                return;
                        }
                        default_print(payloadPtr,
-                             htons(chunkDescPtr->chunkLength) -
+                             EXTRACT_16BITS(&chunkDescPtr->chunkLength) -
                              (sizeof(struct sctpDataPart)+
                              sizeof(struct sctpChunkDesc)));
                } else