]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix bpf for the correct position on new buffers.
authorRoy Marples <roy@marples.name>
Thu, 15 May 2008 12:32:27 +0000 (12:32 +0000)
committerRoy Marples <roy@marples.name>
Thu, 15 May 2008 12:32:27 +0000 (12:32 +0000)
bpf.c
client.c
net.c

diff --git a/bpf.c b/bpf.c
index a674069e9c0daf789e31b6afbd52b98d5f1d8075..f39a7470502f55908d6d9c33492032e3b6b707c0 100644 (file)
--- a/bpf.c
+++ b/bpf.c
@@ -92,7 +92,7 @@ open_socket(struct interface *iface, int protocol)
        /* Get the required BPF buffer length from the kernel. */
        if (ioctl(fd, BIOCGBLEN, &buf_len) == -1)
                goto eexit;
-       if (iface->buffer_size != buf_len) {
+       if (iface->buffer_size != (size_t)buf_len) {
                free(iface->buffer);
                iface->buffer_size = buf_len;
                iface->buffer = xmalloc(buf_len);
@@ -172,6 +172,7 @@ get_packet(struct interface *iface, void *data, ssize_t len)
                        else if ((size_t)bytes < sizeof(packet))
                                return -1;
                        iface->buffer_len = bytes;
+                       iface->buffer_pos = 0;
                }
                bytes = -1;
                memcpy(&packet, iface->buffer + iface->buffer_pos,
index 9d14334807b3e3bb18ad50963f5dd0c59c6faf2f..c7cd378be9758fb4e19167a2aafa51158ce41e1d 100644 (file)
--- a/client.c
+++ b/client.c
@@ -1219,7 +1219,7 @@ handle_packet(struct if_state *state, const struct options *options)
                }
                if (handle_dhcp(state, &dhcp, options) == 0)
                        return 0;
-       } while (iface->buffer_pos != 0);
+       } while (iface->buffer_len != 0);
 
        free(dhcp);
        return -1;
diff --git a/net.c b/net.c
index 388f2674c6569a24452bc8a4213a543dbf0d282c..490d59a9c37dcf3ab05af60d20a550f18e371790 100644 (file)
--- a/net.c
+++ b/net.c
@@ -783,7 +783,7 @@ arp_claim(struct interface *iface, struct in_addr address)
                               hwaddr_ntoa((unsigned char *)&reply_mac, (size_t)reply.ar_hln));
                        retval = -1;
                        goto eexit;
-               } while (iface->buffer_pos != 0);
+               } while (iface->buffer_len != 0);
        }
 
 eexit: