summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2011-08-09 13:24:43 -0700
committerSam Roberts <vieuxtech@gmail.com>2011-08-09 13:24:43 -0700
commit998cb2598815814a86410317accd53df57c8a182 (patch)
treef69a3a30c07d3fccb6517ac4bfbd3220ab5021ca
parent113fc91b6104e00a6cbc2f654e02af1f31e3ea2f (diff)
parent284ccd01da691288e30bf42349140147c03b014d (diff)
downloadlibnet-998cb2598815814a86410317accd53df57c8a182.tar.gz
Merge branch 'master' of github.com:sam-github/libnet
-rw-r--r--libnet/src/libnet_build_dhcp.c11
-rw-r--r--libnet/src/libnet_build_hsrp.c2
-rw-r--r--libnet/src/libnet_build_icmp.c4
-rw-r--r--libnet/src/libnet_build_rip.c6
4 files changed, 10 insertions, 13 deletions
diff --git a/libnet/src/libnet_build_dhcp.c b/libnet/src/libnet_build_dhcp.c
index ed80230..d147958 100644
--- a/libnet/src/libnet_build_dhcp.c
+++ b/libnet/src/libnet_build_dhcp.c
@@ -83,8 +83,7 @@ libnet_t *l, libnet_ptag_t ptag)
if (chaddr)
{
- memcpy(dhcp_hdr.dhcp_chaddr, chaddr, sizeof (dhcp_hdr.dhcp_chaddr));
- dhcp_hdr.dhcp_chaddr[sizeof(dhcp_hdr.dhcp_chaddr) - 1] = 0;
+ strncpy((char *)dhcp_hdr.dhcp_chaddr, (const char *)chaddr, sizeof (dhcp_hdr.dhcp_chaddr) - 2);
}
else
{
@@ -93,8 +92,7 @@ libnet_t *l, libnet_ptag_t ptag)
if (sname)
{
- memcpy(dhcp_hdr.dhcp_sname, sname, sizeof (dhcp_hdr.dhcp_sname));
- dhcp_hdr.dhcp_sname[sizeof(dhcp_hdr.dhcp_sname) - 1] = 0;
+ strncpy((const char *)dhcp_hdr.dhcp_sname, (char *)sname, sizeof (dhcp_hdr.dhcp_sname) - 2);
}
else
{
@@ -103,8 +101,7 @@ libnet_t *l, libnet_ptag_t ptag)
if (file)
{
- memcpy(dhcp_hdr.dhcp_file, file, sizeof (dhcp_hdr.dhcp_file));
- dhcp_hdr.dhcp_file[sizeof(dhcp_hdr.dhcp_file) - 1] = 0;
+ strncpy(dhcp_hdr.dhcp_file, file, sizeof (dhcp_hdr.dhcp_file) - 2);
}
else
{
@@ -153,4 +150,4 @@ libnet_t *l, libnet_ptag_t ptag)
l, ptag));
}
-/* EOF */
+/* EOF */ \ No newline at end of file
diff --git a/libnet/src/libnet_build_hsrp.c b/libnet/src/libnet_build_hsrp.c
index 7c03749..8f56945 100644
--- a/libnet/src/libnet_build_hsrp.c
+++ b/libnet/src/libnet_build_hsrp.c
@@ -57,7 +57,7 @@ const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
* Find the existing protocol block if a ptag is specified, or create
* a new one.
*/
- p = libnet_pblock_probe(l, ptag, LIBNET_HSRP_H, LIBNET_PBLOCK_HSRP_H);
+ p = libnet_pblock_probe(l, ptag, LIBNET_HSRP_H + payload_s, LIBNET_PBLOCK_HSRP_H);
if (p == NULL)
{
return (-1);
diff --git a/libnet/src/libnet_build_icmp.c b/libnet/src/libnet_build_icmp.c
index 7233b3e..d46590f 100644
--- a/libnet/src/libnet_build_icmp.c
+++ b/libnet/src/libnet_build_icmp.c
@@ -313,7 +313,7 @@ const uint8_t *payload, uint32_t payload_s, libnet_t *l, libnet_ptag_t ptag)
}
/* size of memory block */
- n = LIBNET_ICMPV4_TIMXCEED_H;
+ n = LIBNET_ICMPV4_TIMXCEED_H + payload_s;
/*
* FREDRAYNAL: as ICMP checksum includes what is embedded in
* the payload, and what is after the ICMP header, we need to include
@@ -362,7 +362,7 @@ libnet_ptag_t ptag)
return (-1);
}
- n = LIBNET_ICMPV4_REDIRECT_H; /* size of memory block */
+ n = LIBNET_ICMPV4_REDIRECT_H + payload_s; /* size of memory block */
/*
* FREDRAYNAL: as ICMP checksum includes what is embedded in
* the payload, and what is after the ICMP header, we need to include
diff --git a/libnet/src/libnet_build_rip.c b/libnet/src/libnet_build_rip.c
index 911d0cf..52a2db7 100644
--- a/libnet/src/libnet_build_rip.c
+++ b/libnet/src/libnet_build_rip.c
@@ -73,9 +73,9 @@ libnet_ptag_t ptag)
rip_hdr.rip_rd = htons(rd);
rip_hdr.rip_af = htons(af);
rip_hdr.rip_rt = htons(rt);
- rip_hdr.rip_addr = htonl(addr);
- rip_hdr.rip_mask = htonl(mask);
- rip_hdr.rip_next_hop = htonl(next_hop);
+ rip_hdr.rip_addr = addr;
+ rip_hdr.rip_mask = mask;
+ rip_hdr.rip_next_hop = next_hop;
rip_hdr.rip_metric = htonl(metric);
n = libnet_pblock_append(l, p, (uint8_t *)&rip_hdr, LIBNET_RIP_H);