summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2004-05-04 18:58:50 +0000
committerderaadt <deraadt@openbsd.org>2004-05-04 18:58:50 +0000
commit8cfc80846deecc2824076c62fa963afe2f7477b4 (patch)
tree4e7e42b60a54441bf65d57ddc3affda0220be620
parent$OpenBSD$ (diff)
downloadwireguard-openbsd-8cfc80846deecc2824076c62fa963afe2f7477b4.tar.xz
wireguard-openbsd-8cfc80846deecc2824076c62fa963afe2f7477b4.zip
more shrink and lint fixes; henning ok
-rw-r--r--sbin/dhclient/alloc.c10
-rw-r--r--sbin/dhclient/bpf.c16
-rw-r--r--sbin/dhclient/clparse.c4
-rw-r--r--sbin/dhclient/dhclient.c114
-rw-r--r--sbin/dhclient/dhcpd.h33
-rw-r--r--sbin/dhclient/dispatch.c4
-rw-r--r--sbin/dhclient/hash.c8
-rw-r--r--sbin/dhclient/packet.c14
-rw-r--r--sbin/dhclient/privsep.c10
9 files changed, 97 insertions, 116 deletions
diff --git a/sbin/dhclient/alloc.c b/sbin/dhclient/alloc.c
index 3301035aabf..de129a1b650 100644
--- a/sbin/dhclient/alloc.c
+++ b/sbin/dhclient/alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alloc.c,v 1.7 2004/04/14 20:22:27 henning Exp $ */
+/* $OpenBSD: alloc.c,v 1.8 2004/05/04 18:58:50 deraadt Exp $ */
/* Memory allocation... */
@@ -43,7 +43,7 @@
#include "dhcpd.h"
struct string_list *
-new_string_list(size_t size, char * name)
+new_string_list(size_t size)
{
struct string_list *rval;
@@ -54,7 +54,7 @@ new_string_list(size_t size, char * name)
}
struct hash_table *
-new_hash_table(int count, char *name)
+new_hash_table(int count)
{
struct hash_table *rval;
@@ -68,7 +68,7 @@ new_hash_table(int count, char *name)
}
struct hash_bucket *
-new_hash_bucket(char *name)
+new_hash_bucket(void)
{
struct hash_bucket *rval = calloc(1, sizeof(struct hash_bucket));
@@ -76,7 +76,7 @@ new_hash_bucket(char *name)
}
void
-free_hash_bucket(struct hash_bucket *ptr, char *name)
+free_hash_bucket(struct hash_bucket *ptr)
{
free(ptr);
}
diff --git a/sbin/dhclient/bpf.c b/sbin/dhclient/bpf.c
index 64d8c5f0077..b906849e3da 100644
--- a/sbin/dhclient/bpf.c
+++ b/sbin/dhclient/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.10 2004/03/02 18:49:21 deraadt Exp $ */
+/* $OpenBSD: bpf.c,v 1.11 2004/05/04 18:58:50 deraadt Exp $ */
/* BPF socket interface code, originally contributed by Archie Cobbs. */
@@ -182,9 +182,9 @@ if_register_receive(struct interface_info *info)
}
ssize_t
-send_packet(struct interface_info *interface, struct packet *packet,
- struct dhcp_packet *raw, size_t len, struct in_addr from,
- struct sockaddr_in *to, struct hardware *hto)
+send_packet(struct interface_info *interface, struct dhcp_packet *raw,
+ size_t len, struct in_addr from, struct sockaddr_in *to,
+ struct hardware *hto)
{
unsigned char buf[256];
struct iovec iov[2];
@@ -192,7 +192,7 @@ send_packet(struct interface_info *interface, struct packet *packet,
/* Assemble the headers... */
assemble_hw_header(interface, buf, &bufp, hto);
- assemble_udp_ip_header(interface, buf, &bufp, from.s_addr,
+ assemble_udp_ip_header(buf, &bufp, from.s_addr,
to->sin_addr.s_addr, to->sin_port, (unsigned char *)raw, len);
/* Fire it off */
@@ -274,8 +274,8 @@ receive_packet(struct interface_info *interface, unsigned char *buf,
interface->rbuf_offset += hdr.bh_hdrlen;
/* Decode the physical header... */
- offset = decode_hw_header(interface,
- interface->rbuf, interface->rbuf_offset, hfrom);
+ offset = decode_hw_header(interface->rbuf,
+ interface->rbuf_offset, hfrom);
/*
* If a physical layer checksum failed (dunno of any
@@ -290,7 +290,7 @@ receive_packet(struct interface_info *interface, unsigned char *buf,
hdr.bh_caplen -= offset;
/* Decode the IP and UDP headers... */
- offset = decode_udp_ip_header(interface, interface->rbuf,
+ offset = decode_udp_ip_header(interface->rbuf,
interface->rbuf_offset, from, NULL, hdr.bh_caplen);
/* If the IP or UDP checksum was bad, skip the packet... */
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 751f80f5d29..248d71d073a 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.12 2004/03/02 18:49:21 deraadt Exp $ */
+/* $OpenBSD: clparse.c,v 1.13 2004/05/04 18:58:50 deraadt Exp $ */
/* Parser for dhclient config and lease files... */
@@ -882,7 +882,7 @@ parse_string_list(FILE *cfile, struct string_list **lp, int multiple)
return;
}
- tmp = new_string_list(strlen(val) + 1, "parse tmp");
+ tmp = new_string_list(strlen(val) + 1);
if (tmp == NULL)
error("no memory for string list entry.");
strlcpy(tmp->string, val, strlen(val) + 1);
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index be190856fbf..83bfd1031f2 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.38 2004/05/04 12:52:05 henning Exp $ */
+/* $OpenBSD: dhclient.c,v 1.39 2004/05/04 18:58:50 deraadt Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -199,10 +199,10 @@ routehandler(struct protocol *p)
return;
die:
- script_init(ifi, "FAIL", NULL);
+ script_init("FAIL", NULL);
if (ifi->client->alias)
- script_write_params(ifi, "alias_", ifi->client->alias);
- script_go(ifi);
+ script_write_params("alias_", ifi->client->alias);
+ script_go();
exit(1);
}
@@ -460,14 +460,14 @@ state_selecting(void *ipp)
/* Check to see if we got an ARPREPLY for the address
in this particular lease. */
if (!picked) {
- script_init(ip, "ARPCHECK", lp->medium);
- script_write_params(ip, "check_", lp);
+ script_init("ARPCHECK", lp->medium);
+ script_write_params("check_", lp);
/* If the ARPCHECK code detects another
machine using the offered address, it exits
nonzero. We need to send a DHCPDECLINE and
toss the lease. */
- if (script_go(ip)) {
+ if (script_go()) {
make_decline(ip, lp);
send_decline(ip);
goto freeit;
@@ -610,16 +610,16 @@ bind_lease(struct interface_info *ip)
write_client_lease(ip, ip->client->new, 0);
/* Run the client script with the new parameters. */
- script_init(ip, (ip->client->state == S_REQUESTING ? "BOUND" :
+ script_init((ip->client->state == S_REQUESTING ? "BOUND" :
(ip->client->state == S_RENEWING ? "RENEW" :
(ip->client->state == S_REBOOTING ? "REBOOT" : "REBIND"))),
ip->client->new->medium);
if (ip->client->active && ip->client->state != S_REBOOTING)
- script_write_params(ip, "old_", ip->client->active);
- script_write_params(ip, "new_", ip->client->new);
+ script_write_params("old_", ip->client->active);
+ script_write_params("new_", ip->client->new);
if (ip->client->alias)
- script_write_params(ip, "alias_", ip->client->alias);
- script_go(ip);
+ script_write_params("alias_", ip->client->alias);
+ script_go();
/* Replace the old active lease with the new one. */
if (ip->client->active)
@@ -784,11 +784,11 @@ dhcpoffer(struct packet *packet)
lease->medium = ip->client->medium;
/* Send out an ARP Request for the offered IP address. */
- script_init(ip, "ARPSEND", lease->medium);
- script_write_params(ip, "check_", lease);
+ script_init("ARPSEND", lease->medium);
+ script_write_params("check_", lease);
/* If the script can't send an ARP request without waiting,
we'll be waiting when we do the ARPCHECK, so don't wait now. */
- if (script_go(ip))
+ if (script_go())
arp_timeout_needed = 0;
else
arp_timeout_needed = 2;
@@ -972,10 +972,7 @@ void
send_discover(void *ipp)
{
struct interface_info *ip = ipp;
-
- int result;
- int interval;
- int increase = 1;
+ int interval, increase = 1;
/* Figure out how long it's been since we started transmitting. */
interval = cur_time - ip->client->first_sending;
@@ -1007,8 +1004,8 @@ again:
note("Trying medium \"%s\" %d", ip->client->medium->string,
increase);
- script_init(ip, "MEDIUM", ip->client->medium);
- if (script_go(ip))
+ script_init("MEDIUM", ip->client->medium);
+ if (script_go())
goto again;
}
@@ -1059,8 +1056,8 @@ again:
ntohs(sockaddr_broadcast.sin_port), ip->client->interval);
/* Send out a packet. */
- result = send_packet(ip, NULL, &ip->client->packet,
- ip->client->packet_length, inaddr_any, &sockaddr_broadcast, NULL);
+ (void)send_packet(ip, &ip->client->packet, ip->client->packet_length,
+ inaddr_any, &sockaddr_broadcast, NULL);
add_timeout(cur_time + ip->client->interval, send_discover, ip);
}
@@ -1075,7 +1072,6 @@ void
state_panic(void *ipp)
{
struct interface_info *ip = ipp;
-
struct client_lease *loop = ip->client->active;
struct client_lease *lp;
@@ -1093,17 +1089,17 @@ state_panic(void *ipp)
piaddr(ip->client->active->address));
/* Run the client script with the existing
parameters. */
- script_init(ip, "TIMEOUT",
+ script_init("TIMEOUT",
ip->client->active->medium);
- script_write_params(ip, "new_", ip->client->active);
+ script_write_params("new_", ip->client->active);
if (ip->client->alias)
- script_write_params(ip, "alias_",
+ script_write_params("alias_",
ip->client->alias);
/* If the old lease is still good and doesn't
yet need renewal, go into BOUND state and
timeout at the renewal time. */
- if (!script_go(ip)) {
+ if (!script_go()) {
if (cur_time <
ip->client->active->renewal) {
ip->client->state = S_BOUND;
@@ -1155,10 +1151,10 @@ activate_next:
tell the shell script that we failed to allocate an address,
and try again later. */
note("No working leases in persistent database - sleeping.\n");
- script_init(ip, "FAIL", NULL);
+ script_init("FAIL", NULL);
if (ip->client->alias)
- script_write_params(ip, "alias_", ip->client->alias);
- script_go(ip);
+ script_write_params("alias_", ip->client->alias);
+ script_go();
ip->client->state = S_INIT;
add_timeout(cur_time + ip->client->config->retry_interval, state_init,
ip);
@@ -1169,11 +1165,9 @@ void
send_request(void *ipp)
{
struct interface_info *ip = ipp;
-
- int result;
- int interval;
struct sockaddr_in destination;
struct in_addr from;
+ int interval;
/* Figure out how long it's been since we started transmitting. */
interval = cur_time - ip->client->first_sending;
@@ -1203,10 +1197,10 @@ cancel:
if (ip->client->state == S_REBOOTING &&
!ip->client->medium &&
ip->client->active->medium ) {
- script_init(ip, "MEDIUM", ip->client->active->medium);
+ script_init("MEDIUM", ip->client->active->medium);
/* If the medium we chose won't fly, go to INIT state. */
- if (script_go(ip))
+ if (script_go())
goto cancel;
/* Record the medium. */
@@ -1218,18 +1212,18 @@ cancel:
if (ip->client->state != S_REQUESTING &&
cur_time > ip->client->active->expiry) {
/* Run the client script with the new parameters. */
- script_init(ip, "EXPIRE", NULL);
- script_write_params(ip, "old_", ip->client->active);
+ script_init("EXPIRE", NULL);
+ script_write_params("old_", ip->client->active);
if (ip->client->alias)
- script_write_params(ip, "alias_", ip->client->alias);
- script_go(ip);
+ script_write_params("alias_", ip->client->alias);
+ script_go();
/* Now do a preinit on the interface so that we can
discover a new address. */
- script_init(ip, "PREINIT", NULL);
+ script_init("PREINIT", NULL);
if (ip->client->alias)
- script_write_params(ip, "alias_", ip->client->alias);
- script_go(ip);
+ script_write_params("alias_", ip->client->alias);
+ script_go();
ip->client->state = S_INIT;
state_init(ip);
@@ -1293,8 +1287,8 @@ cancel:
inet_ntoa(destination.sin_addr), ntohs(destination.sin_port));
/* Send out a packet. */
- result = send_packet(ip, NULL, &ip->client->packet,
- ip->client->packet_length, from, &destination, NULL);
+ (void) send_packet(ip, &ip->client->packet, ip->client->packet_length,
+ from, &destination, NULL);
add_timeout(cur_time + ip->client->interval, send_request, ip);
}
@@ -1303,15 +1297,14 @@ void
send_decline(void *ipp)
{
struct interface_info *ip = ipp;
- int result;
note("DHCPDECLINE on %s to %s port %d", ip->name,
inet_ntoa(sockaddr_broadcast.sin_addr),
ntohs(sockaddr_broadcast.sin_port));
/* Send out a packet. */
- result = send_packet(ip, NULL, &ip->client->packet,
- ip->client->packet_length, inaddr_any, &sockaddr_broadcast, NULL);
+ (void) send_packet(ip, &ip->client->packet, ip->client->packet_length,
+ inaddr_any, &sockaddr_broadcast, NULL);
}
void
@@ -1319,25 +1312,22 @@ send_release(void *ipp)
{
struct interface_info *ip = ipp;
- int result;
-
note("DHCPRELEASE on %s to %s port %d", ip->name,
inet_ntoa(sockaddr_broadcast.sin_addr),
ntohs(sockaddr_broadcast.sin_port));
/* Send out a packet. */
- result = send_packet(ip, NULL, &ip->client->packet,
- ip->client->packet_length, inaddr_any, &sockaddr_broadcast, NULL);
+ (void) send_packet(ip, &ip->client->packet, ip->client->packet_length,
+ inaddr_any, &sockaddr_broadcast, NULL);
}
void
make_discover(struct interface_info *ip, struct client_lease *lease)
{
unsigned char discover = DHCPDISCOVER;
- int i;
-
struct tree_cache *options[256];
struct tree_cache option_elements[256];
+ int i;
memset(option_elements, 0, sizeof(option_elements));
memset(options, 0, sizeof(options));
@@ -1421,10 +1411,9 @@ void
make_request(struct interface_info *ip, struct client_lease * lease)
{
unsigned char request = DHCPREQUEST;
- int i;
-
struct tree_cache *options[256];
struct tree_cache option_elements[256];
+ int i;
memset(options, 0, sizeof(options));
memset(&ip->client->packet, 0, sizeof(ip->client->packet));
@@ -1529,13 +1518,12 @@ void
make_decline(struct interface_info *ip, struct client_lease *lease)
{
unsigned char decline = DHCPDECLINE;
- int i;
-
struct tree_cache *options[256];
struct tree_cache message_type_tree;
struct tree_cache requested_address_tree;
struct tree_cache server_id_tree;
struct tree_cache client_id_tree;
+ int i;
memset(options, 0, sizeof(options));
memset(&ip->client->packet, 0, sizeof(ip->client->packet));
@@ -1610,11 +1598,10 @@ void
make_release(struct interface_info *ip, struct client_lease *lease)
{
unsigned char request = DHCPRELEASE;
- int i;
-
struct tree_cache *options[256];
struct tree_cache message_type_tree;
struct tree_cache server_id_tree;
+ int i;
memset(options, 0, sizeof(options));
memset(&ip->client->packet, 0, sizeof(ip->client->packet));
@@ -1765,7 +1752,7 @@ char scriptName[256];
FILE *scriptFile;
void
-script_init(struct interface_info *ip, char *reason, struct string_list *medium)
+script_init(char *reason, struct string_list *medium)
{
struct imsg_hdr hdr;
struct buf *buf;
@@ -1955,8 +1942,7 @@ supersede:
}
void
-script_write_params(struct interface_info *ip, char *prefix,
- struct client_lease *lease)
+script_write_params(char *prefix, struct client_lease *lease)
{
struct imsg_hdr hdr;
struct buf *buf;
@@ -2007,7 +1993,7 @@ script_write_params(struct interface_info *ip, char *prefix,
}
int
-script_go(struct interface_info *ip)
+script_go(void)
{
struct imsg_hdr hdr;
struct buf *buf;
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 3c6783247b0..8b0f867e740 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.29 2004/05/04 12:52:05 henning Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.30 2004/05/04 18:58:50 deraadt Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -290,18 +290,17 @@ struct dns_host_entry *enter_dns_host(char *);
pair cons(caddr_t, pair);
/* alloc.c */
-struct string_list *new_string_list(size_t size, char * name);
-struct hash_table *new_hash_table(int, char *);
-struct hash_bucket *new_hash_bucket(char *);
-void free_hash_bucket(struct hash_bucket *, char *);
+struct string_list *new_string_list(size_t size);
+struct hash_table *new_hash_table(int);
+struct hash_bucket *new_hash_bucket(void);
+void free_hash_bucket(struct hash_bucket *);
/* bpf.c */
int if_register_bpf(struct interface_info *);
void if_register_send(struct interface_info *);
void if_register_receive(struct interface_info *);
-ssize_t send_packet(struct interface_info *,
- struct packet *, struct dhcp_packet *, size_t, struct in_addr,
- struct sockaddr_in *, struct hardware *);
+ssize_t send_packet(struct interface_info *, struct dhcp_packet *, size_t,
+ struct in_addr, struct sockaddr_in *, struct hardware *);
ssize_t receive_packet(struct interface_info *, unsigned char *, size_t,
struct sockaddr_in *, struct hardware *);
@@ -391,10 +390,9 @@ void priv_script_init(char *, char *);
void priv_script_write_params(char *, struct client_lease *);
int priv_script_go(void);
-void script_init(struct interface_info *, char *, struct string_list *);
-void script_write_params(struct interface_info *,
- char *, struct client_lease *);
-int script_go(struct interface_info *);
+void script_init(char *, struct string_list *);
+void script_write_params(char *, struct client_lease *);
+int script_go(void);
void client_envadd(struct client_state *,
const char *, const char *, const char *, ...);
void script_set_env(struct client_state *, const char *, const char *,
@@ -412,12 +410,11 @@ void dhcp(struct packet *);
/* packet.c */
void assemble_hw_header(struct interface_info *, unsigned char *,
int *, struct hardware *);
-void assemble_udp_ip_header(struct interface_info *, unsigned char *,
- int *, u_int32_t, u_int32_t, unsigned int, unsigned char *, int);
-ssize_t decode_hw_header(struct interface_info *, unsigned char *,
- int, struct hardware *);
-ssize_t decode_udp_ip_header(struct interface_info *, unsigned char *,
- int, struct sockaddr_in *, unsigned char *, int);
+void assemble_udp_ip_header(unsigned char *, int *, u_int32_t, u_int32_t,
+ unsigned int, unsigned char *, int);
+ssize_t decode_hw_header(unsigned char *, int, struct hardware *);
+ssize_t decode_udp_ip_header(unsigned char *, int, struct sockaddr_in *,
+ unsigned char *, int);
/* ethernet.c */
void assemble_ethernet_header(struct interface_info *, unsigned char *,
diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c
index 275a62792ec..2ea7b860a7f 100644
--- a/sbin/dhclient/dispatch.c
+++ b/sbin/dhclient/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.23 2004/04/07 16:27:08 henning Exp $ */
+/* $OpenBSD: dispatch.c,v 1.24 2004/05/04 18:58:50 deraadt Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -241,7 +241,7 @@ got_one(struct protocol *l)
struct sockaddr_in from;
struct hardware hfrom;
struct iaddr ifrom;
- size_t result;
+ ssize_t result;
union {
/*
* Packet input buffer. Must be as large as largest
diff --git a/sbin/dhclient/hash.c b/sbin/dhclient/hash.c
index 1bfc48e9b1f..8457e7ef40a 100644
--- a/sbin/dhclient/hash.c
+++ b/sbin/dhclient/hash.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hash.c,v 1.5 2004/02/07 13:59:45 henning Exp $ */
+/* $OpenBSD: hash.c,v 1.6 2004/05/04 18:58:50 deraadt Exp $ */
/* Routines for manipulating hash tables... */
@@ -47,7 +47,7 @@ static int do_hash(unsigned char *, int, int);
struct hash_table *
new_hash(void)
{
- struct hash_table *rv = new_hash_table(DEFAULT_HASH_SIZE, "new_hash");
+ struct hash_table *rv = new_hash_table(DEFAULT_HASH_SIZE);
if (!rv)
return (rv);
memset(&rv->buckets[0], 0,
@@ -84,7 +84,7 @@ void add_hash(struct hash_table *table, unsigned char *name, int len,
len = strlen((char *)name);
hashno = do_hash(name, len, table->hash_count);
- bp = new_hash_bucket("add_hash");
+ bp = new_hash_bucket();
if (!bp) {
warn("Can't add %s to hash table.", name);
@@ -122,7 +122,7 @@ delete_hash_entry(struct hash_table *table, unsigned char *name, int len)
pbp->next = bp->next;
else
table->buckets[hashno] = bp->next;
- free_hash_bucket(bp, "delete_hash_entry");
+ free_hash_bucket(bp);
break;
}
pbp = bp; /* jwg, 9/6/96 - nice catch! */
diff --git a/sbin/dhclient/packet.c b/sbin/dhclient/packet.c
index a54e2831897..1a22044d40a 100644
--- a/sbin/dhclient/packet.c
+++ b/sbin/dhclient/packet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: packet.c,v 1.8 2004/02/25 14:22:12 henning Exp $ */
+/* $OpenBSD: packet.c,v 1.9 2004/05/04 18:58:50 deraadt Exp $ */
/* Packet assembly code, originally contributed by Archie Cobbs. */
@@ -113,9 +113,8 @@ assemble_hw_header(struct interface_info *interface, unsigned char *buf,
}
void
-assemble_udp_ip_header(struct interface_info *interface, unsigned char *buf,
- int *bufix, u_int32_t from, u_int32_t to, unsigned int port,
- unsigned char *data, int len)
+assemble_udp_ip_header(unsigned char *buf, int *bufix, u_int32_t from,
+ u_int32_t to, unsigned int port, unsigned char *data, int len)
{
struct ip ip;
struct udphdr udp;
@@ -151,8 +150,7 @@ assemble_udp_ip_header(struct interface_info *interface, unsigned char *buf,
}
ssize_t
-decode_hw_header(struct interface_info *interface, unsigned char *buf,
- int bufix, struct hardware *from)
+decode_hw_header(unsigned char *buf, int bufix, struct hardware *from)
{
struct ether_header eh;
@@ -166,8 +164,8 @@ decode_hw_header(struct interface_info *interface, unsigned char *buf,
}
ssize_t
-decode_udp_ip_header(struct interface_info *interface, unsigned char *buf,
- int bufix, struct sockaddr_in *from, unsigned char *data, int buflen)
+decode_udp_ip_header(unsigned char *buf, int bufix, struct sockaddr_in *from,
+ unsigned char *data, int buflen)
{
struct ip *ip;
struct udphdr *udp;
diff --git a/sbin/dhclient/privsep.c b/sbin/dhclient/privsep.c
index 5bf83666421..685d7c62e90 100644
--- a/sbin/dhclient/privsep.c
+++ b/sbin/dhclient/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.4 2004/05/04 18:51:18 henning Exp $ */
+/* $OpenBSD: privsep.c,v 1.5 2004/05/04 18:58:50 deraadt Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -67,7 +67,6 @@ buf_close(int sock, struct buf *buf)
free(buf->buf);
free(buf);
-
return (n);
}
@@ -75,14 +74,15 @@ ssize_t
buf_read(int sock, void *buf, size_t nbytes)
{
ssize_t n, r = 0;
+ char *p = buf;
do {
- n = read(sock, buf, nbytes);
+ n = read(sock, p, nbytes);
if (n == 0)
error("connection closed");
if (n != -1) {
r += n;
- buf += n;
+ p += n;
nbytes -= n;
}
} while (n == -1 && (errno == EINTR || errno == EAGAIN));
@@ -141,6 +141,7 @@ dispatch_imsg(int fd)
free(medium);
break;
case IMSG_SCRIPT_WRITE_PARAMS:
+ bzero(&lease, sizeof lease);
totlen = sizeof(hdr) + sizeof(lease) + sizeof(size_t);
if (hdr.len < totlen)
error("corrupted message received");
@@ -209,7 +210,6 @@ dispatch_imsg(int fd)
for (i = 0; i < 256; i++)
if (lease.options[i].len > 0)
free(lease.options[i].data);
-
break;
case IMSG_SCRIPT_GO:
if (hdr.len != sizeof(hdr))