From 632e1a699e5d1d3edb822b8f55c0b55b9c7e161e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Tue, 11 Mar 2014 15:12:26 +0100 Subject: pcap_io: Only check byteswapped linktype if pcap magic is swapped In pcap_validate_header() the linktype and the byte-swapped linktype are currently checked against the supported linktypes. Since the swapped linktype is always larger than LINKTYPE_MAX, only one of the two tests was actually done. Make this intention a bit more clear by explicitly checking only for either the swapped or non-swapped linktype, depending on whether the pcap magic is swapped. Also make the error messages a bit more verbose regarding the major/minor version. Signed-off-by: Tobias Klauser --- pcap_io.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'pcap_io.h') diff --git a/pcap_io.h b/pcap_io.h index 1fe3b48..454976c 100644 --- a/pcap_io.h +++ b/pcap_io.h @@ -660,27 +660,22 @@ static const bool pcap_supported_linktypes[LINKTYPE_MAX] __maybe_unused = { static inline void pcap_validate_header(const struct pcap_filehdr *hdr) { bool good = false; - uint32_t linktype_swab = bswap_32(hdr->linktype); + uint32_t linktype; + pcap_check_magic(hdr->magic); - if (hdr->linktype < LINKTYPE_MAX) { - if (pcap_supported_linktypes[hdr->linktype]) - good = true; - } - - if (linktype_swab < LINKTYPE_MAX) { - if (pcap_supported_linktypes[linktype_swab]) - good = true; - } + linktype = pcap_magic_is_swapped(hdr->magic) ? bswap_32(hdr->linktype) : hdr->linktype; + if (linktype < LINKTYPE_MAX) + good = pcap_supported_linktypes[linktype]; if (!good) - panic("This file has an unsupported pcap link type (%d)!\n", hdr->linktype); + panic("This file has an unsupported pcap link type (%d)!\n", linktype); if (unlikely(hdr->version_major != PCAP_VERSION_MAJOR) && ___constant_swab16(hdr->version_major) != PCAP_VERSION_MAJOR) - panic("This file has not a valid pcap header\n"); + panic("This file has an invalid pcap major version (must be %d)\n", PCAP_VERSION_MAJOR); if (unlikely(hdr->version_minor != PCAP_VERSION_MINOR) && ___constant_swab16(hdr->version_minor) != PCAP_VERSION_MINOR) - panic("This file has not a valid pcap header\n"); + panic("This file has an invalid pcap minor version (must be %d)\n", PCAP_VERSION_MINOR); } static int pcap_generic_pull_fhdr(int fd, uint32_t *magic, -- cgit v1.2.3-54-g00ecf form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/Documentation/IRQ-affinity.txt'>
diff options
context:
space:
mode:
authorTom Lendacky <thomas.lendacky@amd.com>2016-04-13 10:52:25 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-04-15 22:13:56 +0800
commitf709b45ec461b548c41a00044dba1f1b572783bf (patch)
tree8bf82dcdad57d141c1ff585865bff2ced1fc7c6a /Documentation/IRQ-affinity.txt
parent0851561d9c965df086ef8a53f981f5f95a57c2c8 (diff)
crypto: ccp - Prevent information leakage on export
Prevent information from leaking to userspace by doing a memset to 0 of the export state structure before setting the structure values and copying it. This prevents un-initialized padding areas from being copied into the export area. Cc: <stable@vger.kernel.org> # 3.14.x- Reported-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'Documentation/IRQ-affinity.txt')