diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-08-20 15:53:03 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-09-21 10:29:39 +0200 |
commit | 18fa92c2dcc6c52e0bf27d214d80f0c25a89b47d (patch) | |
tree | a3020ac5b1f366f2f0920941b589808e435dbcee /freebsd/sbin/dhclient | |
parent | Update to FreeBSD head 2017-12-01 (diff) | |
download | rtems-libbsd-18fa92c2dcc6c52e0bf27d214d80f0c25a89b47d.tar.bz2 |
Update to FreeBSD head 2018-02-01
Git mirror commit d079ae0442af8fa3cfd6d7ede190d04e64a2c0d4.
Update #3472.
Diffstat (limited to 'freebsd/sbin/dhclient')
-rw-r--r-- | freebsd/sbin/dhclient/clparse.c | 10 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/conflex.c | 12 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/dhclient.c | 31 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/dhcpd.h | 12 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/inet.c | 4 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/options.c | 29 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/packet.c | 2 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/parse.c | 20 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/privsep.c | 9 | ||||
-rw-r--r-- | freebsd/sbin/dhclient/tree.c | 2 |
10 files changed, 73 insertions, 58 deletions
diff --git a/freebsd/sbin/dhclient/clparse.c b/freebsd/sbin/dhclient/clparse.c index f35c9402..3466d90a 100644 --- a/freebsd/sbin/dhclient/clparse.c +++ b/freebsd/sbin/dhclient/clparse.c @@ -298,12 +298,12 @@ parse_client_statement(FILE *cfile, struct interface_info *ip, } } -int -parse_X(FILE *cfile, u_int8_t *buf, int max) +unsigned +parse_X(FILE *cfile, u_int8_t *buf, unsigned max) { int token; char *val; - int len; + unsigned len; token = peek_token(&val, cfile); if (token == NUMBER_OR_NAME || token == NUMBER) { @@ -687,14 +687,14 @@ parse_option_decl(FILE *cfile, struct option_data *options) int token; u_int8_t buf[4]; u_int8_t hunkbuf[1024]; - int hunkix = 0; + unsigned hunkix = 0; char *vendor; char *fmt; struct universe *universe; struct option *option; struct iaddr ip_addr; u_int8_t *dp; - int len; + unsigned len; int nul_term = 0; token = next_token(&val, cfile); diff --git a/freebsd/sbin/dhclient/conflex.c b/freebsd/sbin/dhclient/conflex.c index fce0458c..73b95d85 100644 --- a/freebsd/sbin/dhclient/conflex.c +++ b/freebsd/sbin/dhclient/conflex.c @@ -62,8 +62,8 @@ int eol_token; static char line1[81]; static char line2[81]; -static int lpos; -static int line; +static unsigned lpos; +static unsigned line; static int tlpos; static int tline; static int token; @@ -230,7 +230,8 @@ skip_to_eol(FILE *cfile) static int read_string(FILE *cfile) { - int i, c, bs = 0; + int c, bs = 0; + unsigned i; for (i = 0; i < sizeof(tokbuf); i++) { c = get_char(cfile); @@ -265,7 +266,8 @@ read_string(FILE *cfile) static int read_number(int c, FILE *cfile) { - int seenx = 0, i = 0, token = NUMBER; + int seenx = 0, token = NUMBER; + unsigned i = 0; tokbuf[i++] = c; for (; i < sizeof(tokbuf); i++) { @@ -292,7 +294,7 @@ read_number(int c, FILE *cfile) static int read_num_or_name(int c, FILE *cfile) { - int i = 0; + unsigned i = 0; int rv = NUMBER_OR_NAME; tokbuf[i++] = c; diff --git a/freebsd/sbin/dhclient/dhclient.c b/freebsd/sbin/dhclient/dhclient.c index b0dabdb8..51fa6081 100644 --- a/freebsd/sbin/dhclient/dhclient.c +++ b/freebsd/sbin/dhclient/dhclient.c @@ -152,7 +152,7 @@ int findproto(char *cp, int n) { struct sockaddr *sa; - int i; + unsigned i; if (n == 0) return -1; @@ -182,7 +182,7 @@ struct sockaddr * get_ifa(char *cp, int n) { struct sockaddr *sa; - int i; + unsigned i; if (n == 0) return (NULL); @@ -197,7 +197,7 @@ get_ifa(char *cp, int n) return (NULL); } -struct iaddr defaddr = { 4 }; +struct iaddr defaddr = { .len = 4 }; uint8_t curbssid[6]; static void @@ -239,7 +239,8 @@ routehandler(struct protocol *p) n = read(routefd, &msg, sizeof(msg)); rtm = (struct rt_msghdr *)msg; - if (n < sizeof(rtm->rtm_msglen) || n < rtm->rtm_msglen || + if (n < (ssize_t)sizeof(rtm->rtm_msglen) || + n < (ssize_t)rtm->rtm_msglen || rtm->rtm_version != RTM_VERSION) return; @@ -2061,7 +2062,8 @@ priv_script_write_params(char *prefix, struct client_lease *lease) { struct interface_info *ip = ifi; u_int8_t dbuf[1500], *dp = NULL; - int i, len; + int i; + size_t len; char tbuf[128]; script_set_env(ip->client, prefix, "ip_address", @@ -2211,12 +2213,14 @@ script_write_params(char *prefix, struct client_lease *lease) pr_len = strlen(prefix); 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) + pr_len; + hdr.len = sizeof(hdr) + sizeof(*lease) + + sizeof(fn_len) + fn_len + sizeof(sn_len) + sn_len + + sizeof(pr_len) + pr_len; - for (i = 0; i < 256; i++) - hdr.len += sizeof(int) + lease->options[i].len; + for (i = 0; i < 256; i++) { + hdr.len += sizeof(lease->options[i].len); + hdr.len += lease->options[i].len; + } scripttime = time(NULL); @@ -2225,7 +2229,7 @@ script_write_params(char *prefix, struct client_lease *lease) errs = 0; errs += buf_add(buf, &hdr, sizeof(hdr)); - errs += buf_add(buf, lease, sizeof(struct client_lease)); + errs += buf_add(buf, lease, sizeof(*lease)); errs += buf_add(buf, &fn_len, sizeof(fn_len)); errs += buf_add(buf, lease->filename, fn_len); errs += buf_add(buf, &sn_len, sizeof(sn_len)); @@ -2330,7 +2334,8 @@ void script_set_env(struct client_state *client, const char *prefix, const char *name, const char *value) { - int i, j, namelen; + int i, namelen; + size_t j; /* No `` or $() command substitution allowed in environment values! */ for (j=0; j < strlen(value); j++) @@ -2398,7 +2403,7 @@ script_flush_env(struct client_state *client) int dhcp_option_ev_name(char *buf, size_t buflen, struct option *option) { - int i; + size_t i; for (i = 0; option->name[i]; i++) { if (i + 1 == buflen) diff --git a/freebsd/sbin/dhclient/dhcpd.h b/freebsd/sbin/dhclient/dhcpd.h index 3fd51ee3..ad64a441 100644 --- a/freebsd/sbin/dhclient/dhcpd.h +++ b/freebsd/sbin/dhclient/dhcpd.h @@ -85,7 +85,7 @@ #define REMOTE_PORT 67 struct option_data { - int len; + size_t len; u_int8_t *data; }; @@ -95,7 +95,7 @@ struct string_list { }; struct iaddr { - int len; + size_t len; unsigned char iabuf[16]; }; @@ -288,9 +288,9 @@ char *parse_string(FILE *); int parse_ip_addr(FILE *, struct iaddr *); void parse_hardware_param(FILE *, struct hardware *); void parse_lease_time(FILE *, time_t *); -unsigned char *parse_numeric_aggregate(FILE *, unsigned char *, int *, - int, int, int); -void convert_num(unsigned char *, char *, int, int); +unsigned char *parse_numeric_aggregate(FILE *, unsigned char *, size_t *, + int, unsigned, int); +void convert_num(unsigned char *, char *, unsigned, int); time_t parse_date(FILE *); /* tree.c */ @@ -427,7 +427,7 @@ int read_client_conf(void); void read_client_leases(void); void parse_client_statement(FILE *, struct interface_info *, struct client_config *); -int parse_X(FILE *, u_int8_t *, int); +unsigned parse_X(FILE *, u_int8_t *, unsigned); int parse_option_list(FILE *, u_int8_t *); void parse_interface_declaration(FILE *, struct client_config *); struct interface_info *interface_or_dummy(char *); diff --git a/freebsd/sbin/dhclient/inet.c b/freebsd/sbin/dhclient/inet.c index 8ed88886..4992ffcb 100644 --- a/freebsd/sbin/dhclient/inet.c +++ b/freebsd/sbin/dhclient/inet.c @@ -58,7 +58,7 @@ struct iaddr subnet_number(struct iaddr addr, struct iaddr mask) { struct iaddr rv; - int i; + unsigned i; rv.len = 0; @@ -81,7 +81,7 @@ struct iaddr broadcast_addr(struct iaddr subnet, struct iaddr mask) { struct iaddr rv; - int i; + unsigned i; if (subnet.len != mask.len) { rv.len = 0; diff --git a/freebsd/sbin/dhclient/options.c b/freebsd/sbin/dhclient/options.c index c08c5c53..fad7dacd 100644 --- a/freebsd/sbin/dhclient/options.c +++ b/freebsd/sbin/dhclient/options.c @@ -57,11 +57,11 @@ int bad_options_max = 5; void parse_options(struct packet *); void parse_option_buffer(struct packet *, unsigned char *, int); -int store_options(unsigned char *, int, struct tree_cache **, +unsigned store_options(unsigned char *, int, struct tree_cache **, unsigned char *, int, int, int, int); void expand_domain_search(struct packet *packet); -int find_search_domain_name_len(struct option_data *option, int *offset); -void expand_search_domain_name(struct option_data *option, int *offset, +int find_search_domain_name_len(struct option_data *option, size_t *offset); +void expand_search_domain_name(struct option_data *option, size_t *offset, unsigned char **domain_search); @@ -215,7 +215,8 @@ parse_option_buffer(struct packet *packet, void expand_domain_search(struct packet *packet) { - int offset, expanded_len, next_domain_len; + size_t offset; + int expanded_len, next_domain_len; struct option_data *option; unsigned char *domain_search, *cursor; @@ -259,9 +260,10 @@ expand_domain_search(struct packet *packet) } int -find_search_domain_name_len(struct option_data *option, int *offset) +find_search_domain_name_len(struct option_data *option, size_t *offset) { - int domain_name_len, i, label_len, pointer, pointed_len; + int domain_name_len, label_len, pointed_len; + size_t i, pointer; domain_name_len = 0; @@ -326,10 +328,11 @@ find_search_domain_name_len(struct option_data *option, int *offset) } void -expand_search_domain_name(struct option_data *option, int *offset, +expand_search_domain_name(struct option_data *option, size_t *offset, unsigned char **domain_search) { - int i, label_len, pointer; + int label_len; + size_t i, pointer; unsigned char *cursor; /* @@ -383,8 +386,10 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, int terminate, int bootpp, u_int8_t *prl, int prl_len) { unsigned char priority_list[300], buffer[4096]; - int priority_len, main_buffer_size, mainbufix, bufix; - int option_size, length; + unsigned priority_len; + size_t main_buffer_size; + unsigned option_size, bufix, mainbufix; + int length; /* * If the client has provided a maximum DHCP message size, use @@ -426,7 +431,7 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, */ if (inpacket && inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].data) { - int prlen = + unsigned prlen = inpacket->options[DHO_DHCP_PARAMETER_REQUEST_LIST].len; if (prlen + priority_len > sizeof(priority_list)) prlen = sizeof(priority_list) - priority_len; @@ -520,7 +525,7 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket, /* * Store all the requested options into the requested buffer. */ -int +unsigned store_options(unsigned char *buffer, int buflen, struct tree_cache **options, unsigned char *priority_list, int priority_len, int first_cutoff, int second_cutoff, int terminate) diff --git a/freebsd/sbin/dhclient/packet.c b/freebsd/sbin/dhclient/packet.c index 40e969ae..b3c719b2 100644 --- a/freebsd/sbin/dhclient/packet.c +++ b/freebsd/sbin/dhclient/packet.c @@ -62,7 +62,7 @@ u_int32_t wrapsum(u_int32_t); u_int32_t checksum(unsigned char *buf, unsigned nbytes, u_int32_t sum) { - int i; + unsigned i; /* Checksum all the pairs of bytes first... */ for (i = 0; i < (nbytes & ~1U); i += 2) { diff --git a/freebsd/sbin/dhclient/parse.c b/freebsd/sbin/dhclient/parse.c index 45234e58..a46f6311 100644 --- a/freebsd/sbin/dhclient/parse.c +++ b/freebsd/sbin/dhclient/parse.c @@ -47,6 +47,8 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include <stdbool.h> + #include "dhcpd.h" #include "dhctoken.h" @@ -160,7 +162,8 @@ void parse_hardware_param(FILE *cfile, struct hardware *hardware) { unsigned char *t; - int token, hlen; + int token; + size_t hlen; char *val; token = next_token(&val, cfile); @@ -244,13 +247,13 @@ parse_lease_time(FILE *cfile, time_t *timep) * tokenized. */ unsigned char * -parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, - int separator, int base, int size) +parse_numeric_aggregate(FILE *cfile, unsigned char *buf, size_t *max, + int separator, unsigned base, int size) { unsigned char *bufp = buf, *s = NULL; - int token, count = 0; + int token; char *val, *t; - size_t valsize; + size_t valsize, count = 0; pair c = NULL; unsigned char *lbufp = NULL; @@ -331,14 +334,15 @@ parse_numeric_aggregate(FILE *cfile, unsigned char *buf, int *max, } void -convert_num(unsigned char *buf, char *str, int base, int size) +convert_num(unsigned char *buf, char *str, unsigned base, int size) { - int negative = 0, tval, max; + bool negative = false; + unsigned tval, max; u_int32_t val = 0; char *ptr = str; if (*ptr == '-') { - negative = 1; + negative = true; ptr++; } diff --git a/freebsd/sbin/dhclient/privsep.c b/freebsd/sbin/dhclient/privsep.c index b1cf5106..0b0d8771 100644 --- a/freebsd/sbin/dhclient/privsep.c +++ b/freebsd/sbin/dhclient/privsep.c @@ -78,7 +78,8 @@ buf_close(int sock, struct buf *buf) ssize_t buf_read(int sock, void *buf, size_t nbytes) { - ssize_t n, r = 0; + ssize_t n; + size_t r = 0; char *p = buf; do { @@ -86,7 +87,7 @@ buf_read(int sock, void *buf, size_t nbytes) if (n == 0) error("connection closed"); if (n != -1) { - r += n; + r += (size_t)n; p += n; nbytes -= n; } @@ -109,9 +110,9 @@ dispatch_imsg(struct interface_info *ifi, int fd) char *medium, *reason, *filename, *servername, *prefix; size_t medium_len, reason_len, filename_len, - servername_len, prefix_len, totlen; + servername_len, optlen, prefix_len, totlen; struct client_lease lease; - int ret, i, optlen; + int ret, i; struct buf *buf; u_int16_t mtu; diff --git a/freebsd/sbin/dhclient/tree.c b/freebsd/sbin/dhclient/tree.c index bc94e2aa..526dd80f 100644 --- a/freebsd/sbin/dhclient/tree.c +++ b/freebsd/sbin/dhclient/tree.c @@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$"); #include "dhcpd.h" -extern int h_errno; - pair cons(caddr_t car, pair cdr) { |