summaryrefslogtreecommitdiff
path: root/sbin/dhclient/options.c
AgeCommit message (Collapse)Author
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.
2013-12-22No need to change format id 'X' (ascii or hex) to 'x' (hex) whileKenneth R Westerback
pretty printing, when 'X' is not used in the next switch statement. Just keep 'X'. Makes the code a touch less mysterious.
2013-12-21Introduce pretty_print_string() and use for printing both textKenneth R Westerback
valued options and previously snprintf()'d filename and servername lease attributes. Should fix "string constant too long" errors when reading back a lease with filename or servername attributes with escaped characters. Reported by Rivo Nurges.
2013-12-18Code existed to print non-printable characters in strings writtenKenneth R Westerback
to the leases file. No code existed to correctly read back the strings so written. Redo both sides and use vis()/strnunvis() instead of handrolling more parsing. As a side-effect allow embedded NUL characters rather than skipping them.
2013-12-14Start cleanup/fixup of pretty printing of option data. Use snprintf()Kenneth R Westerback
exclusively and thus simplify error checking/overflow detection. Bail out when unknown format character found. Don't ignore last character if it's unprintable. Print embedded NULs rather than ignoring them.
2013-12-12Delete spurious blank line.Kenneth R Westerback
2013-12-12Eliminate (most) double decrements of remaining space in the prettyKenneth R Westerback
print buffer. Use consistant idiom to increment pointer to data being consumed, instead of hiding some increments.
2013-12-06Having stopped pretending we handle anything but ethernet packets,Kenneth R Westerback
replace the 'struct hardware' abstraction layer and use 'struct ether_addr' where hardware addresses are of interest. ok matthew@, confirmed by reyk@ not to impact DHCP-over-IPSec support.
2013-07-11Put more debug verbiage under DEBUG. Add a few more debug messages.Kenneth R Westerback
Make packet discarding decisions before parsing the packet's possible options. No intended functional change.
2013-07-07Remove erroneous warnings -- we do not reject offers just because theKenneth R Westerback
option buffer(s) end badly.
2013-07-06Fix a lie in one comment and zap a pointless sentence in another.Kenneth R Westerback
2013-05-02Bunch of comment/whitespace cleanup. Eliminate some misleading orKenneth R Westerback
pointless ones, make multiline comments readable, nuke '...' in favour of '.', etc.
2013-04-05Nuke parameter to do_packet() not used since 2006. From dhill.Kenneth R Westerback
2013-02-14Don't rely on the packet buffer (client->packet) being preserved betweenKenneth R Westerback
attempts to send DISCOVER or REQUEST packets. Some DHCP servers might NAK the DISCOVER, or other nefarious packets arrive, between attempts and overwrite the packet being sent. Create and use another buffer for packets being sent. Problem encountered by fgsch@, who noticed that once the DISCOVER was NAK'ed our dhclient sent a bunch of NAK's back to the server. Like it thought they were DISCOVER messages. ok beck@
2013-01-16Unrevert last reversion. otto@ pointed out that it wasn't asprintf()Kenneth R Westerback
causing a problem, it was accessing uninitialized pointers.
2013-01-16Revert last. asprintf() breaks something.Kenneth R Westerback
2013-01-16Use the magic of asprintf() to produce more informative errorKenneth R Westerback
and log messages.
2013-01-13More informative error message.Kenneth R Westerback
2013-01-13Make pretty_print_option() return "" rather than "<fmt error>" whenKenneth R Westerback
the option fails validation tests. Make pretty_print_option() bail on all bad format strings, and on all incorrect option data lengths. Check pretty_print_option() return value rather than repeating validation with check_option(). Do res_hnok() check on host name, domain name, and nis domain while creating lease from packet info. As a result, nuke ipv4addrs() and check_option(). Ignore options that do not validate rather than summarily rejecting offered lease. Treat all options whose names start with "option-" as unknown rather than relying on a big switch on DHO_ names. Started when reading dhclient(8) -u verbiage.
2012-11-15Shuffle #include's to use the majority idiom everywhere - i.e. useKenneth R Westerback
dhcpd.h to pull in most sys/net/netinet/etc. .h file. Eliminate superfluous #include's.
2012-11-08Remove confusing extra address abstraction 'struct iaddr'. Just useKenneth R Westerback
'in_addr'. Remove many double conversions and other perversions. piaddr() replaced with inet_ntoa(). dhclient is extremely unlikely to support anything but ipv4/dhcp without a complete rewrite. Joint work with chris@. Positive feedback from deraadt@ zinke@ phessler@.
2012-11-07Use memset() consistently rather than tossing in a few bzero()'s.Kenneth R Westerback
2012-10-27Change dhclient.conf directive 'ignore' to take a list of option namesKenneth R Westerback
rather than list of option declarations. e.g. 'ignore routers;' instead of 'ignore routers 1.2.3.4;' The value in the declaration was being ignored anyway. While there clean up the related code a bit.
2012-06-26Add some more paranoia and make code clearer. Check that the requiredKenneth R Westerback
length field for the option is present before using it. Reject lease if no length field is present.
2012-06-26RFC 2132 says "Options containing NVT ASCII data SHOULD NOT includeKenneth R Westerback
a trailing NULL; however, the receiver of such options MUST be prepared to delete trailing nulls if they exist." So delete (all) trailing NUL's when parsing NVT ASCII options. Should fix odd results when 'append'ing info to such options via dhclient.conf. FreeBSD commit to fix 'append' logic in a different way pointed out by brad.
2011-05-11Make dhclient more friendly to sequential option processing byKenneth R Westerback
always starting DHCP packet options with DHO_DHCP_MESSAGE_TYPE. Now DHCP-specific options always come after the option identifying the packet as DHCP rather than BOOTP. Makes at least Nortel NetIP DHCP server happier. Clean up some code and parameter passing. Closes PR#6543, as confirmed by original submitter and patch tester Len Zaifman. Thanks! ok matthew@ (who hates the ISC-like code)
2011-04-17fix a possible division by zero if a server sends us a broken optionPeter Hessler
hints for the proper fix, and OK claudio@ (this was lost in my tree for far too long)
2009-03-10Add 6-byte MAC address to the log entries for DHCP ACK/NAK/OFFER.Kenneth R Westerback
Log the packets before checking the client state. Makes it easy to find MACs for 'surprise' DHCP servers. Positive comments from mbalmer@, jasper@.
2007-06-02safer snprintf construct with more paranoid length calculationPeter Valchev
ok millert
2007-05-31fix a funny memory miscalculation bug in options parsingPeter Valchev
ok henning otto theo
2007-02-14spacing and a typo that fell out of the readTheo de Raadt
2007-01-25Cleanup some more code. Eliminate dhcp(), bootp(), parse_options() byKenneth R Westerback
moving the minimal code into do_packet(). Eliminate repeated code for checking the client hardware address and the reject list by putting those checks into do_packet as well. No functional change, just much easier to read. ok stevesk@
2007-01-16More cleanup. Eliminate 'struct packet' by cleverly passing asKenneth R Westerback
parameters just those things actually needed and using existing structs and information. No functional change. ok stevesk@
2007-01-14Don't treat any packet with an invalid option buffer or an invalidKenneth R Westerback
message type option of 0 as a BOOTP offer. Don't process any option buffer after one is found to be corrupt. Don't process overflow buffers in a BOOTP packet. At least try to accept DHCP offers even if a bad options buffer is encountered. Brings code more into line with current ISC dhclient. ok stevesk@
2007-01-11Reject all packets with an option claiming to extend past the end ofKenneth R Westerback
an option buffer. No longer accept the 6th such packet. From ISC. ok ckuethe@ stevesk@
2007-01-06Fix options parsing. Last commit lost the proper length of theKenneth R Westerback
incoming packet. But since we bzero() the packet buffer before copying the incoming data into it, and the options are at the end, and we use a fixed sized buffer, and 0's are ignored as pad options, and proper option lists end with 0xff, it's simplier to always try to scan the whole buffer. Problem found by, and patch tested by kettenis@.
2007-01-04Another round of cleanup. There is only one instance of structKenneth R Westerback
dhcp_packet and it is contained in the global *client. So don't pass around pointers to a struct that contains a pointer to the dhcp_packet instance. Just use the global client->packet. Eliminate unused struct packet members and parameter lists accordingly. No functional change. Suggestions by stevesk@. ok stevesk@
2006-12-26Our dhclient only handles one interface. Simplify code by using theKenneth R Westerback
single, global, instance of 'struct interface_info' (ifi) rather than passing around pointers to it. "I agree" henning@ Testing moritz@ stevesk@, ok stevesk@
2006-12-15typo in commentKevin Steves
2005-08-22Fix problems with some Linksys DHCP servers (and probably others) byKenneth R Westerback
not accidentally inserting two NULL characters after each option in the DHCPREQUEST packet. Thanks to Christian Jones for the problem report and tcpdump's, and to Emmett Pate for finding a problematic Linksys model still in my local stores. ok deraadt@
2005-07-16back out last; breaks in cases where we want hex and the last byte is 0Henning Brauer
2005-07-15let pretty_print_option() handle trailing nul bytes correctly (i. e. don'tHenning Brauer
let a trailing nul byte force hex printing) FreeBSD PR 83468 by Sean Winn <sean@gothic.net.au>, via jmc@
2005-07-13spacingTheo de Raadt
2005-07-13Repair/rationalize option handling to ensure valid option section isKenneth R Westerback
always sent. Fold store_options into cons_options. Eliminate priority list of options. ok deraadt@