diff options
author | Denis Kenzior <denkenz@gmail.com> | 2011-06-29 05:00:56 -0500 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-06-29 05:00:56 -0500 |
commit | 2eb4611de8eb1fc874b59b757abfe90b30851d1f (patch) | |
tree | 71fefbfa04692ac8bd64573ae62256a844c1d61b /gatchat/ppp_net.c | |
parent | e893deac59f35ea30a65f24217d565181b54c400 (diff) | |
download | ofono-2eb4611de8eb1fc874b59b757abfe90b30851d1f.tar.bz2 |
ppp: Add basic length sanity checks
Diffstat (limited to 'gatchat/ppp_net.c')
-rw-r--r-- | gatchat/ppp_net.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c index 7ce7bc81..edce8366 100644 --- a/gatchat/ppp_net.c +++ b/gatchat/ppp_net.c @@ -77,16 +77,22 @@ gboolean ppp_net_set_mtu(struct ppp_net *net, guint16 mtu) return TRUE; } -void ppp_net_process_packet(struct ppp_net *net, const guint8 *packet) +void ppp_net_process_packet(struct ppp_net *net, const guint8 *packet, + gsize plen) { GIOStatus status; gsize bytes_written; guint16 len; + if (plen < 4) + return; + /* find the length of the packet to transmit */ len = get_host_short(&packet[2]); status = g_io_channel_write_chars(net->channel, (gchar *) packet, - len, &bytes_written, NULL); + MIN(len, plen), + &bytes_written, NULL); + if (status != G_IO_STATUS_NORMAL) return; } |