diff options
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r-- | networking/udhcp/options.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 3168fc69a..2b4f1644f 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c | |||
@@ -73,12 +73,13 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) | |||
73 | { | 73 | { |
74 | int i, length; | 74 | int i, length; |
75 | uint8_t *optionptr; | 75 | uint8_t *optionptr; |
76 | int over = 0, done = 0, curr = OPTION_FIELD; | 76 | int over = 0; |
77 | int curr = OPTION_FIELD; | ||
77 | 78 | ||
78 | optionptr = packet->options; | 79 | optionptr = packet->options; |
79 | i = 0; | 80 | i = 0; |
80 | length = 308; | 81 | length = sizeof(packet->options); |
81 | while (!done) { | 82 | while (1) { |
82 | if (i >= length) { | 83 | if (i >= length) { |
83 | bb_error_msg("bogus packet, option fields too long"); | 84 | bb_error_msg("bogus packet, option fields too long"); |
84 | return NULL; | 85 | return NULL; |
@@ -103,17 +104,18 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) | |||
103 | i += optionptr[OPT_LEN] + 2; | 104 | i += optionptr[OPT_LEN] + 2; |
104 | break; | 105 | break; |
105 | case DHCP_END: | 106 | case DHCP_END: |
106 | if (curr == OPTION_FIELD && over & FILE_FIELD) { | 107 | if (curr == OPTION_FIELD && (over & FILE_FIELD)) { |
107 | optionptr = packet->file; | 108 | optionptr = packet->file; |
108 | i = 0; | 109 | i = 0; |
109 | length = 128; | 110 | length = sizeof(packet->file); |
110 | curr = FILE_FIELD; | 111 | curr = FILE_FIELD; |
111 | } else if (curr == FILE_FIELD && over & SNAME_FIELD) { | 112 | } else if (curr == FILE_FIELD && (over & SNAME_FIELD)) { |
112 | optionptr = packet->sname; | 113 | optionptr = packet->sname; |
113 | i = 0; | 114 | i = 0; |
114 | length = 64; | 115 | length = sizeof(packet->sname); |
115 | curr = SNAME_FIELD; | 116 | curr = SNAME_FIELD; |
116 | } else done = 1; | 117 | } else |
118 | return NULL; | ||
117 | break; | 119 | break; |
118 | default: | 120 | default: |
119 | i += optionptr[OPT_LEN + i] + 2; | 121 | i += optionptr[OPT_LEN + i] + 2; |