summaryrefslogtreecommitdiff
path: root/networking/udhcp/options.c
diff options
context:
space:
mode:
Diffstat (limited to 'networking/udhcp/options.c')
-rw-r--r--networking/udhcp/options.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c
index 3168fc6..2b4f164 100644
--- a/networking/udhcp/options.c
+++ b/networking/udhcp/options.c
@@ -73,12 +73,13 @@ uint8_t *get_option(struct dhcpMessage *packet, int code)
{
int i, length;
uint8_t *optionptr;
- int over = 0, done = 0, curr = OPTION_FIELD;
+ int over = 0;
+ int curr = OPTION_FIELD;
optionptr = packet->options;
i = 0;
- length = 308;
- while (!done) {
+ length = sizeof(packet->options);
+ while (1) {
if (i >= length) {
bb_error_msg("bogus packet, option fields too long");
return NULL;
@@ -103,17 +104,18 @@ uint8_t *get_option(struct dhcpMessage *packet, int code)
i += optionptr[OPT_LEN] + 2;
break;
case DHCP_END:
- if (curr == OPTION_FIELD && over & FILE_FIELD) {
+ if (curr == OPTION_FIELD && (over & FILE_FIELD)) {
optionptr = packet->file;
i = 0;
- length = 128;
+ length = sizeof(packet->file);
curr = FILE_FIELD;
- } else if (curr == FILE_FIELD && over & SNAME_FIELD) {
+ } else if (curr == FILE_FIELD && (over & SNAME_FIELD)) {
optionptr = packet->sname;
i = 0;
- length = 64;
+ length = sizeof(packet->sname);
curr = SNAME_FIELD;
- } else done = 1;
+ } else
+ return NULL;
break;
default:
i += optionptr[OPT_LEN + i] + 2;