diff options
author | Jiri Popelka <jpopelka@redhat.com> | 2011-06-08 18:05:20 +0200 |
---|---|---|
committer | Jiri Popelka <jpopelka@redhat.com> | 2011-06-08 18:05:20 +0200 |
commit | c2190b9713ebf4419410dcb1a4074d1cdb1f0a1a (patch) | |
tree | 10363f664dca9a8bac1214fa50607f16a8831d34 | |
parent | 4aac7af2c41d3381c424020824b56fdb5baa0706 (diff) | |
download | libnet-c2190b9713ebf4419410dcb1a4074d1cdb1f0a1a.tar.gz |
Coverity: CHECKED_RETURN
libnet_build_tcp.c: check return value of libnet_pblock_append()
(as is done elsewhere 143 out of 145 times).
-rw-r--r-- | libnet/src/libnet_build_tcp.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/libnet/src/libnet_build_tcp.c b/libnet/src/libnet_build_tcp.c index f064ee9..8150170 100644 --- a/libnet/src/libnet_build_tcp.c +++ b/libnet/src/libnet_build_tcp.c @@ -143,7 +143,8 @@ libnet_build_tcp( goto bad; } - if (libnet_pblock_append(l, p_data, payload, payload_s) == -1) + n = libnet_pblock_append(l, p_data, payload, payload_s); + if (n == -1) { goto bad; } @@ -188,7 +189,7 @@ libnet_build_tcp_options(const uint8_t *options, uint32_t options_s, libnet_t *l libnet_ptag_t ptag) { static const uint8_t padding[] = { 0 }; - int offset, underflow; + int n, offset, underflow; uint32_t i, j, adj_size; libnet_pblock_t *p, *p_temp; struct libnet_ipv4_hdr *ip_hdr; @@ -244,10 +245,19 @@ libnet_ptag_t ptag) { return (-1); } - - libnet_pblock_append(l, p, options, options_s); - libnet_pblock_append(l, p, padding, adj_size - options_s); - + + n = libnet_pblock_append(l, p, options, options_s); + if (n == -1) + { + goto bad; + } + + n = libnet_pblock_append(l, p, padding, adj_size - options_s); + if (n == -1) + { + goto bad; + } + if (ptag && p->next) { p_temp = p->next; @@ -296,6 +306,9 @@ libnet_ptag_t ptag) return (ptag ? ptag : libnet_pblock_update(l, p, adj_size, LIBNET_PBLOCK_TCPO_H)); +bad: + libnet_pblock_delete(l, p); + return (-1); } /* EOF */ |