projects
/
silc.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8298858
)
Packet engine: moved packet sanity checks after MAC check
author
Pekka Riikonen
<priikone@silcnet.org>
Sun, 23 Nov 2008 10:56:20 +0000
(12:56 +0200)
committer
Pekka Riikonen
<priikone@silcnet.org>
Sun, 23 Nov 2008 10:56:20 +0000
(12:56 +0200)
lib/silccore/silcpacket.c
patch
|
blob
|
history
diff --git
a/lib/silccore/silcpacket.c
b/lib/silccore/silcpacket.c
index f552ca6d1741aebf31648e1c694d34c302792ac3..8b68c5ed17d00ddca0bb61f4456d9b0e33cc0d5b 100644
(file)
--- a/
lib/silccore/silcpacket.c
+++ b/
lib/silccore/silcpacket.c
@@
-2197,17
+2197,6
@@
static void silc_packet_read_process(SilcPacketStream stream)
/* Get packet length and full packet length with padding */
SILC_PACKET_LENGTH(header, packetlen, paddedlen);
/* Get packet length and full packet length with padding */
SILC_PACKET_LENGTH(header, packetlen, paddedlen);
- /* Sanity checks */
- if (silc_unlikely(packetlen < SILC_PACKET_MIN_LEN)) {
- if (!stream->udp && !silc_socket_stream_is_udp(stream->stream, NULL))
- SILC_LOG_ERROR(("Received too short packet"));
- silc_mutex_unlock(stream->lock);
- SILC_PACKET_CALLBACK_ERROR(stream, SILC_PACKET_ERR_MALFORMED);
- silc_mutex_lock(stream->lock);
- memset(tmp, 0, sizeof(tmp));
- goto out;
- }
-
if (silc_buffer_len(inbuf) < paddedlen + ivlen + mac_len) {
SILC_LOG_DEBUG(("Received partial packet, waiting for the rest "
"(%d bytes)",
if (silc_buffer_len(inbuf) < paddedlen + ivlen + mac_len) {
SILC_LOG_DEBUG(("Received partial packet, waiting for the rest "
"(%d bytes)",
@@
-2231,6
+2220,17
@@
static void silc_packet_read_process(SilcPacketStream stream)
goto out;
}
goto out;
}
+ /* Sanity checks */
+ if (silc_unlikely(packetlen < SILC_PACKET_MIN_LEN)) {
+ if (!stream->udp && !silc_socket_stream_is_udp(stream->stream, NULL))
+ SILC_LOG_ERROR(("Received too short packet"));
+ silc_mutex_unlock(stream->lock);
+ SILC_PACKET_CALLBACK_ERROR(stream, SILC_PACKET_ERR_MALFORMED);
+ silc_mutex_lock(stream->lock);
+ memset(tmp, 0, sizeof(tmp));
+ goto out;
+ }
+
/* Get packet */
packet = silc_packet_alloc(stream->sc->engine);
if (silc_unlikely(!packet)) {
/* Get packet */
packet = silc_packet_alloc(stream->sc->engine);
if (silc_unlikely(!packet)) {