aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/common.c')
-rw-r--r--networking/udhcp/common.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c
index e5fd74f91..41b05b855 100644
--- a/networking/udhcp/common.c
+++ b/networking/udhcp/common.c
@@ -272,6 +272,15 @@ uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code)
272 goto complain; /* complain and return NULL */ 272 goto complain; /* complain and return NULL */
273 273
274 if (optionptr[OPT_CODE] == code) { 274 if (optionptr[OPT_CODE] == code) {
275 if (optionptr[OPT_LEN] == 0) {
276 /* So far no valid option with length 0 known.
277 * Having this check means that searching
278 * for DHCP_MESSAGE_TYPE need not worry
279 * that returned pointer might be unsafe
280 * to dereference.
281 */
282 goto complain; /* complain and return NULL */
283 }
275 log_option("option found", optionptr); 284 log_option("option found", optionptr);
276 return optionptr + OPT_DATA; 285 return optionptr + OPT_DATA;
277 } 286 }
@@ -289,6 +298,16 @@ uint8_t* FAST_FUNC udhcp_get_option(struct dhcp_packet *packet, int code)
289 return NULL; 298 return NULL;
290} 299}
291 300
301uint8_t* FAST_FUNC udhcp_get_option32(struct dhcp_packet *packet, int code)
302{
303 uint8_t *r = udhcp_get_option(packet, code);
304 if (r) {
305 if (r[-1] != 4)
306 r = NULL;
307 }
308 return r;
309}
310
292/* Return the position of the 'end' option (no bounds checking) */ 311/* Return the position of the 'end' option (no bounds checking) */
293int FAST_FUNC udhcp_end_option(uint8_t *optionptr) 312int FAST_FUNC udhcp_end_option(uint8_t *optionptr)
294{ 313{