diff options
author | 2004-05-05 23:07:47 +0000 | |
---|---|---|
committer | 2004-05-05 23:07:47 +0000 | |
commit | a14c9f7367cd062fa89e7db66fcf4baa19d711cd (patch) | |
tree | 000d8d6e5c9a281f02590f73a8c4649db433f116 | |
parent | spacing (diff) | |
download | wireguard-openbsd-a14c9f7367cd062fa89e7db66fcf4baa19d711cd.tar.xz wireguard-openbsd-a14c9f7367cd062fa89e7db66fcf4baa19d711cd.zip |
knf
-rw-r--r-- | sbin/dhclient/dhclient.c | 64 | ||||
-rw-r--r-- | sbin/dhclient/dispatch.c | 4 | ||||
-rw-r--r-- | sbin/dhclient/parse.c | 19 |
3 files changed, 34 insertions, 53 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index ae4549dcf92..251c45d7500 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.47 2004/05/05 22:21:03 deraadt Exp $ */ +/* $OpenBSD: dhclient.c,v 1.48 2004/05/05 23:07:47 deraadt Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -1505,12 +1505,10 @@ make_request(struct interface_info *ip, struct client_lease * lease) void make_decline(struct interface_info *ip, struct client_lease *lease) { - unsigned char decline = DHCPDECLINE; - struct tree_cache *options[256]; - struct tree_cache message_type_tree; + struct tree_cache *options[256], message_type_tree; struct tree_cache requested_address_tree; - struct tree_cache server_id_tree; - struct tree_cache client_id_tree; + struct tree_cache server_id_tree, client_id_tree; + unsigned char decline = DHCPDECLINE; int i; memset(options, 0, sizeof(options)); @@ -1623,9 +1621,9 @@ void write_client_lease(struct interface_info *ip, struct client_lease *lease, int rewrite) { - int i; - struct tm *t; static int leases_written; + struct tm *t; + int i; if (!rewrite) { if (leases_written++ > 20) { @@ -1683,11 +1681,10 @@ write_client_lease(struct interface_info *ip, struct client_lease *lease, void script_init(char *reason, struct string_list *medium) { + size_t len, mediumlen = 0; struct imsg_hdr hdr; struct buf *buf; int errs; - size_t len; - size_t mediumlen = 0; if (medium != NULL && medium->string != NULL) mediumlen = strlen(medium->string); @@ -1747,11 +1744,10 @@ priv_script_init(char *reason, char *medium) void priv_script_write_params(char *prefix, struct client_lease *lease) { - int i; + struct interface_info *ip = ifi; u_int8_t dbuf[1500]; - int len = 0; + int i, len = 0; char tbuf[128]; - struct interface_info *ip = ifi; script_set_env(ip->client, prefix, "ip_address", piaddr(lease->address)); @@ -1761,8 +1757,7 @@ priv_script_write_params(char *prefix, struct client_lease *lease) sizeof(lease->address.iabuf))) { struct iaddr netmask, subnet, broadcast; - memcpy(netmask.iabuf, - lease->options[DHO_SUBNET_MASK].data, + memcpy(netmask.iabuf, lease->options[DHO_SUBNET_MASK].data, lease->options[DHO_SUBNET_MASK].len); netmask.len = lease->options[DHO_SUBNET_MASK].len; @@ -1860,8 +1855,9 @@ supersede: } if (len) { char name[256]; + if (dhcp_option_ev_name(name, sizeof(name), - &dhcp_options[i])) + &dhcp_options[i])) script_set_env(ip->client, prefix, name, pretty_print_option(i, dp, len, 0, 0)); } @@ -1873,10 +1869,10 @@ supersede: void script_write_params(char *prefix, struct client_lease *lease) { + size_t fn_len = 0, sn_len = 0, pr_len = 0; struct imsg_hdr hdr; struct buf *buf; int errs, i; - size_t fn_len = 0, sn_len = 0, pr_len= 0; if (lease->filename != NULL) fn_len = strlen(lease->filename); @@ -1887,8 +1883,7 @@ script_write_params(char *prefix, struct client_lease *lease) hdr.code = IMSG_SCRIPT_WRITE_PARAMS; hdr.len = sizeof(hdr) + sizeof(struct client_lease) + - sizeof(size_t) + fn_len + - sizeof(size_t) + sn_len + + sizeof(size_t) + fn_len + sizeof(size_t) + sn_len + sizeof(size_t) + pr_len; for (i = 0; i < 256; i++) @@ -1954,14 +1949,10 @@ script_go(void) int priv_script_go(void) { - char *scriptName; - char *argv[2]; - char **envp; - char *epp[3]; - char reason[] = "REASON=NBI"; + char *scriptName, *argv[2], **envp, *epp[3], reason[] = "REASON=NBI"; static char client_path[] = CLIENT_PATH; - int pid, wpid, wstatus; struct interface_info *ip = ifi; + int pid, wpid, wstatus; if (ip) { scriptName = ip->client->config->script_name; @@ -2022,6 +2013,7 @@ script_set_env(struct client_state *client, const char *prefix, if (i >= client->scriptEnvsize - 1) { char **newscriptEnv; int newscriptEnvsize = client->scriptEnvsize + 50; + newscriptEnv = realloc(client->scriptEnv, newscriptEnvsize); if (newscriptEnv == NULL) { @@ -2260,20 +2252,14 @@ option_as_string(unsigned int code, unsigned char *data, int len) error("option_as_string: bad code %d\n", code); for (; dp < data + len; dp++) { - if (!isascii(*dp) || - !isprint(*dp)) { - if (dp + 1 != data + len || - *dp != 0) { - snprintf(op, opleft, - "\\%03o", *dp); + if (!isascii(*dp) || !isprint(*dp)) { + if (dp + 1 != data + len || *dp != 0) { + snprintf(op, opleft, "\\%03o", *dp); op += 4; opleft -= 4; } - } else if (*dp == '"' || - *dp == '\'' || - *dp == '$' || - *dp == '`' || - *dp == '\\') { + } else if (*dp == '"' || *dp == '\'' || *dp == '$' || + *dp == '`' || *dp == '\\') { *op++ = '\\'; *op++ = *dp; opleft -= 2; @@ -2291,12 +2277,11 @@ toobig: return "<error>"; } - int fork_privchld(int fd, int fd2) { - int nfds; - struct pollfd pfd[1]; + struct pollfd pfd[1]; + int nfds; switch (fork()) { case -1: @@ -2328,4 +2313,3 @@ fork_privchld(int fd, int fd2) dispatch_imsg(fd); } } - diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 0465ae8d7ba..e5181bc7d5f 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.27 2004/05/04 22:23:01 mickey Exp $ */ +/* $OpenBSD: dispatch.c,v 1.28 2004/05/05 23:07:47 deraadt Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -66,8 +66,8 @@ static int interface_status(struct interface_info *ifinfo); void discover_interfaces(struct interface_info *iface) { - struct sockaddr_in foo; struct ifaddrs *ifap, *ifa; + struct sockaddr_in foo; struct ifreq *tif; if (getifaddrs(&ifap) != 0) diff --git a/sbin/dhclient/parse.c b/sbin/dhclient/parse.c index 1c7bd2f1152..e8870bc12ae 100644 --- a/sbin/dhclient/parse.c +++ b/sbin/dhclient/parse.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.c,v 1.10 2004/05/04 22:23:01 mickey Exp $ */ +/* $OpenBSD: parse.c,v 1.11 2004/05/05 23:07:47 deraadt Exp $ */ /* Common parser code for dhcpd and dhclient. */ @@ -60,8 +60,7 @@ void skip_to_semi(FILE *cfile) { - int brace_count = 0; - int token; + int brace_count = 0, token; char *val; do { @@ -113,9 +112,8 @@ parse_semi(FILE *cfile) char * parse_string(FILE *cfile) { - char *val; + char *val, *s; int token; - char *s; token = next_token(&val, cfile); if (token != STRING) { @@ -189,8 +187,8 @@ parse_hardware_param(FILE *cfile, struct hardware *hardware) parse_warn("hardware address too long"); } else { hardware->hlen = hlen; - memcpy((unsigned char *)&hardware->haddr[0], - t, hardware->hlen); + memcpy((unsigned char *)&hardware->haddr[0], t, + hardware->hlen); if (hlen < sizeof(hardware->haddr)) memset(&hardware->haddr[hlen], 0, sizeof(hardware->haddr) - hlen); @@ -427,12 +425,11 @@ convert_num(unsigned char *buf, char *str, int base, int size) time_t parse_date(FILE *cfile) { - struct tm tm; - int guess; - char *val; - int token; static int months[11] = { 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; + int guess, token; + struct tm tm; + char *val; /* Day of week... */ token = next_token(&val, cfile); |