0005-udhcpc-when-decoding-DHCP_SUBNET-ensure-it-is-4-bytes-long.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 74d9f1ba37010face4bd1449df4d60dd84450b06 Mon Sep 17 00:00:00 2001
  2. From: Denys Vlasenko <vda.linux@googlemail.com>
  3. Date: Mon, 7 Jan 2019 15:33:42 +0100
  4. Subject: udhcpc: when decoding DHCP_SUBNET, ensure it is 4 bytes long
  5. function old new delta
  6. udhcp_run_script 795 801 +6
  7. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
  8. Signed-off-by: Jared Bents <jared.bents@rockwellcollins.com>
  9. ---
  10. networking/udhcp/common.c | 2 +-
  11. networking/udhcp/common.h | 2 +-
  12. networking/udhcp/dhcpc.c | 2 +-
  13. 3 files changed, 3 insertions(+), 3 deletions(-)
  14. diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
  15. index 4c2221b77..fc4de5716 100644
  16. --- a/networking/udhcp/common.c
  17. +++ b/networking/udhcp/common.c
  18. @@ -302,7 +302,7 @@ uint8_t* FAST_FUNC udhcp_get_option32(struct dhcp_packet *packet, int code)
  19. {
  20. uint8_t *r = udhcp_get_option(packet, code);
  21. if (r) {
  22. - if (r[-1] != 4)
  23. + if (r[-OPT_DATA + OPT_LEN] != 4)
  24. r = NULL;
  25. }
  26. return r;
  27. diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
  28. index 9511152ff..62f9a2a4a 100644
  29. --- a/networking/udhcp/common.h
  30. +++ b/networking/udhcp/common.h
  31. @@ -119,7 +119,7 @@ enum {
  32. //#define DHCP_TIME_SERVER 0x04 /* RFC 868 time server (32-bit, 0 = 1.1.1900) */
  33. //#define DHCP_NAME_SERVER 0x05 /* IEN 116 _really_ ancient kind of NS */
  34. //#define DHCP_DNS_SERVER 0x06
  35. -//#define DHCP_LOG_SERVER 0x07 /* port 704 UDP log (not syslog)
  36. +//#define DHCP_LOG_SERVER 0x07 /* port 704 UDP log (not syslog) */
  37. //#define DHCP_COOKIE_SERVER 0x08 /* "quote of the day" server */
  38. //#define DHCP_LPR_SERVER 0x09
  39. #define DHCP_HOST_NAME 0x0c /* 12: either client informs server or server gives name to client */
  40. diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
  41. index 5b3fd531c..dcec8cdfd 100644
  42. --- a/networking/udhcp/dhcpc.c
  43. +++ b/networking/udhcp/dhcpc.c
  44. @@ -531,7 +531,7 @@ static char **fill_envp(struct dhcp_packet *packet)
  45. temp = udhcp_get_option(packet, code);
  46. *curr = xmalloc_optname_optval(temp, &dhcp_optflags[i], opt_name);
  47. putenv(*curr++);
  48. - if (code == DHCP_SUBNET) {
  49. + if (code == DHCP_SUBNET && temp[-OPT_DATA + OPT_LEN] == 4) {
  50. /* Subnet option: make things like "$ip/$mask" possible */
  51. uint32_t subnet;
  52. move_from_unaligned32(subnet, temp);
  53. --
  54. cgit v1.2.1