summaryrefslogtreecommitdiff
path: root/sbin/dhclient/options.c
AgeCommit message (Collapse)Author
2018-07-22No need to re-implement realloc(). Just use itKenneth R Westerback
the way the man page says. ok tb@
2018-07-22Tweak comment about truncating NULs to reflect newKenneth R Westerback
reality.
2018-07-22When finished pulling an option out of a buffer, skip directly to theKenneth R Westerback
next option. Don't rely on truncated NULs being ignored because NUL == DHO_PAD. ok tb@
2018-07-21Reading past the end of a buffer is bad, Even if theKenneth R Westerback
extra byte is always there. Even if the byte contains innocuous data that isn't used. Eeven if a particular level of optimization of a particular compiler avoids it by processing things backwards. Bad. So simplify and correct logic. Perhaps even proof the code against future generations of clever compilers. Pointed out by Brandon Falk. Thanks! ok millert@ tb@
2017-10-11Repair printing of classless-static-routes to leasesKenneth R Westerback
file. Broken due to incorrect translation from a netmask to the count of leading 1's. Use brute force counting until something better is found. Issue discovered and diffs tested by Anthony Coulter via bugs@. Thanks!
2017-09-20Wrong captilization, long lines.Kenneth R Westerback
2017-09-17Create global 'log_procname' and set it to '<ifname>' orKenneth R Westerback
'<ifname> [priv]' as appropriate for the process doing the setting. Use it as the prefix in all log_*() output. Makes tracking messages for an interface or a process much easier.
2017-09-14Strive to rationalize fatal[x]() usage andKenneth R Westerback
verbiage.
2017-09-09Tweak extract_classless_route() to return unsigned intKenneth R Westerback
and accept NULL pointers for unwanted components of the route.
2017-09-01Two stray "if (p)" -> "if (p != NULL)" andKenneth R Westerback
a stray "if (char)" -> "if (char != '\0').
2017-08-29Add a utility function extract_classless_route() andKenneth R Westerback
use it to simplify logic at both places that process RFC 3442 data.
2017-08-28No need for pretty_print_classless() to useKenneth R Westerback
an internal 8K static buffer whose contents are simply copied into another 8K buffer in the caller. Just pass a pointer to and length of the outer buffer.
2017-07-14Replace remaining "!var" expressions withKenneth R Westerback
"<var> == 0", "!(<var> & FLAG)" with "(<var> & FLAG) == 0", "!<func()>" with "<func()> == 0" and "!<define>" with "<define> == 0". And the positive cases as well. A few stray == NULL and != NULL as well.
2017-07-14Replace remaining "!<pointer>" expressions withKenneth R Westerback
"<pointer> == NULL". And of course "<pointer>" expressions with "<pointer> != NULL".
2017-07-10Use a modern spacious idiom on all function local variableKenneth R Westerback
declarations.
2017-07-09Be consistent. "return (e);" -> "return e;"Kenneth R Westerback
2017-07-08Fold tables.c into options.c and stop exporting the oneKenneth R Westerback
table (dhcp_options) involved. Provide functions code_to_name(), name_to_code(), code_to_format() and replace direct access to dhcp_options with them. Eliminate unneeded 'struct option'. Unhook tables.c from Makefile.
2017-07-08Always use uintNN_t instead of sometimes u_intNN_tKenneth R Westerback
and sometimes uintNN_t.
2017-07-07Replace the many occurances of '256' with a new #defineKenneth R Westerback
DHO_COUNT.
2017-07-07Rename cons_options() to pack_options(), and do_packet() toKenneth R Westerback
unpack_options(). Store the unpacked options in a static variable. Move remaining raw packet processing from unpack_options() to packethandler(). No more struct interface_info knowledge in options.c
2017-07-06cons_options() only needs to know a buffer and a length toKenneth R Westerback
pack options into. Not all the gory details of interface_info. Move some of the raw packet processing out of options.c's do_packet() and into the more obvious dispatch.c's packethandler(). Mention that RFC791 is why we use 576-byte UDP packets.
2017-06-15Nuke unused parameter 'client_addr' from the 'handlers', i.e.Kenneth R Westerback
dhcpoffer(), dhcpack(), dhcpnak().
2017-06-14Move xid, secs, first_sending, startup_time fields fromKenneth R Westerback
client_state to interface_info. No intentional functional change.
2017-06-14Start consolidating client_state into interface_info. FirstKenneth R Westerback
fields to move: recv_packet, sent_packet and sent_packet_length. No intentional functional change.
2017-06-13Rename 'packet' field to 'recv_packet' and 'bootrequest_packet'Kenneth R Westerback
field to 'sent_packet'. Also 'bootrequest_packet_length' to 'sent_packet_length'. Adopt consistent idiom of a local variable 'packet' to point at packet being manipulated. No intentional functional change.
2017-04-09Seven casts, a couple of tweaks and CFLAGS+=-Wsign-compare for theKenneth R Westerback
win. No intentional functional change.
2017-04-08Reduce the overburden of signed vs unsigned comparisons by sprinklingKenneth R Westerback
'int' -> 'unsigned int' (and visa versa) where obvious. Steal a couple of 'unsigned' -> u_int32_t from reyk@'s dhcrelay tweaks. No intentional functional change.
2017-04-08Replace another snprintf() dance with easier to read code usingKenneth R Westerback
strlcat(). Shorter, clearer, fewer signed vs unsigned questions. Use an 8K static buffer for pretty_print_classless() and use it rather scribbling intermediate values into the final destination. No intentional functional change.
2017-04-08Replace a mess of snprintf() dances with easier to read code usingKenneth R Westerback
strlcat(). Shorter, clearer, fewer signed vs unsigned questions. Shrink static buffer for the string version of an option value from 32K to 8K. Since the string version of the entire lease is constructed in a 8K buffer, bigger option values are pointless. Use 8K of the saved space for a static buffer for pretty_print_string() and use it rather scribbling intermediate values into the final destination. No intentional functional change.
2017-04-07Simply decoding of domain search option. No intentional functionalKenneth R Westerback
change.
2017-03-26Fix dhclient vis/unvis of strings stored in the leases file.Kenneth R Westerback
Replaces incorrect manual emulation of vis() for single, double and back quotes, dollar signs and back slashes. Just use vis() with VIS_ALL for these characters. Should fix problem reported by robert@ with ssid's containing back slash.
2017-03-08Add comments to #endif's to allow easy differentiation between manyKenneth R Westerback
incoming #ifdef's.
2017-02-12Adjust lines that are too long.Kenneth R Westerback
2017-02-12Switch from 'legacy' errwarn.c to standard daemon logging functions.Kenneth R Westerback
No objections heard. Feedback from millert@ guenther@
2016-10-06Add support for RFC 6842, which says the client MUST drop packets whenKenneth R Westerback
the server provides a client-identifier value and it doesn't match the value the client sent. So stop suppressing client-identifer info in the leases file and when reading the leases file stop discarding leases that don't have current client-identifier info. Don't use them, but keep them around in case the client-identifier info changes back next time. Also construct the default client-identifier (if needed) before reading the leases file.
2016-09-02Kill 'ifi' global.Martin Pieuchot
ok henning@, krw@
2016-08-31Remove the 'client' global and make it per-ifp.Martin Pieuchot
ok krw@
2016-08-23Make the 'ifi' global local to dhclient.c and pass it as an argument toMartin Pieuchot
functions needing it. This is the first step to support multiple interfaces in one dhclient(8) instance. ok krw@
2016-02-06Eliminate #include inside *.h files and include only needed headers inKenneth R Westerback
each *.c file. Inspired by mention of header silliness by Edgar Pettijohn and mmcc@ on tech@.
2015-10-26Give dhclient(8) the ability to use option 119, a.k.a. "DomainKenneth R Westerback
Search" if supplied by the server. Requested by a few. Original diff from Ray Lai via tech@. Tested & ok claudio@
2014-10-27Nuke getLong(), getShort(), getUShort(). Two line functions (memcpy();Kenneth R Westerback
ntoh[ls]()) obscure rather than simplify things. Especially when they are used only once. Just use the expansion.
2014-10-27htonl(ntohl(memcpy'd buf)) seems like the long way around to copyKenneth R Westerback
an IPv4 address. Just memcpy() it.
2014-10-27Zap extraneous whitespace and a stuttered extra 'break;'.Kenneth R Westerback
2014-07-28Fix memory exhaustion occurring on DHCP options with 0 length.Tobias Stoeckmann
halex@ and krw@ pointed out that a NULL check before free can go, too. ok deraadt@, halex@, krw@
2014-07-09Special case pretty printing of DHO_CLASSLESS_STATIC_ROUTES andKenneth R Westerback
DHO_CLASSLESS_MS_STATIC_ROUTES. Remove 'C' (CIDR) pretty printing outside of those special cases. Add a bunch of paranoia to protect against confused/malicious dhcp servers. Since 'C' is a variable size element it can't be handled by the existing code, which is designed for fixed size elements. Issue found by Someya Yuuichi, reported by yasuoka@ who also provided the first diff. ok yasuoka@
2014-05-05Zap trailing whitespace. Started by pointed comments from andre@.Kenneth R Westerback
2014-01-21Add parsing for options 121 (classless-static-routes) and 249Kenneth R Westerback
(classless-ms-static-routes). dhcpd can now specify and serve these options and dhclient can recognize and use supersede, etc. statements on them. Based on a diff from Stefan Rinke. Thanks!
2014-01-19We don't have any (and I can't find elsewhere) signed 16 bit orKenneth R Westerback
signed 8 bit dhcp option types. So nuke getShort() and all 's' and 'b' format support. While here use '%u'/'%lu' and not '%d'/'%ld' to snprintf() unsigned values.
2013-12-30Replace yet another hand-rolled list with a TAILQ. reject_list thisKenneth R Westerback
time.
2013-12-22Setting format id to 't' when it's already 't' is a waste ofKenneth R Westerback
time.