From: Dustin Kirkland <kirkland@canonical.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] net socket verify packet size
Date: Tue, 24 Feb 2009 11:38:49 -0600 [thread overview]
Message-ID: <d9c105ea0902240938l5e2c024fid92c77629b3e4829@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 192 bytes --]
net socket oversized packet
This is a patch being carried by Ubuntu against kvm/qemu.
Verify packet size before performing memcpy().
Signed-off-by: Dustin Kirkland <kirkland@canonical.com>
[-- Attachment #2: net-socket.patch --]
[-- Type: text/x-diff, Size: 1472 bytes --]
diff -urpN kvm_84+dfsg.new/qemu/net.c kvm_84+dfsg.new.new/qemu/net.c
--- kvm_84+dfsg.new/qemu/net.c 2009-02-12 09:19:26.000000000 -0600
+++ kvm_84+dfsg.new.new/qemu/net.c 2009-02-16 16:50:57.195796925 -0600
@@ -1246,8 +1246,8 @@ typedef struct NetSocketState {
VLANClientState *vc;
int fd;
int state; /* 0 = getting length, 1 = getting data */
- int index;
- int packet_len;
+ unsigned int index;
+ unsigned int packet_len;
uint8_t buf[4096];
struct sockaddr_in dgram_dst; /* contains inet host and port destination iff connectionless (SOCK_DGRAM) */
} NetSocketState;
@@ -1280,7 +1280,8 @@ static void net_socket_receive_dgram(voi
static void net_socket_send(void *opaque)
{
NetSocketState *s = opaque;
- int l, size, err;
+ int size, err;
+ unsigned l;
uint8_t buf1[4096];
const uint8_t *buf;
@@ -1319,7 +1320,15 @@ static void net_socket_send(void *opaque
l = s->packet_len - s->index;
if (l > size)
l = size;
- memcpy(s->buf + s->index, buf, l);
+ if (s->index + l <= sizeof(s->buf)) {
+ memcpy(s->buf + s->index, buf, l);
+ } else {
+ fprintf(stderr, "serious error: oversized packet received,"
+ "connection terminated.\n");
+ s->state = 0;
+ goto eoc;
+ }
+
s->index += l;
buf += l;
size -= l;
next reply other threads:[~2009-02-24 17:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-24 17:38 Dustin Kirkland [this message]
2009-02-27 19:54 ` [Qemu-devel] [PATCH] net socket verify packet size Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d9c105ea0902240938l5e2c024fid92c77629b3e4829@mail.gmail.com \
--to=kirkland@canonical.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).