diff options
Diffstat (limited to 'networking/udhcp/files.c')
-rw-r--r-- | networking/udhcp/files.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 9ade4ae6d..775f829dd 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c | |||
@@ -101,19 +101,8 @@ static void attach_option(struct option_set **opt_list, | |||
101 | { | 101 | { |
102 | struct option_set *existing, *new, **curr; | 102 | struct option_set *existing, *new, **curr; |
103 | 103 | ||
104 | /* add it to an existing option */ | ||
105 | existing = find_option(*opt_list, option->code); | 104 | existing = find_option(*opt_list, option->code); |
106 | if (existing) { | 105 | if (!existing) { |
107 | DEBUG("Attaching option %s to existing member of list", option->name); | ||
108 | if (option->flags & OPTION_LIST) { | ||
109 | if (existing->data[OPT_LEN] + length <= 255) { | ||
110 | existing->data = realloc(existing->data, | ||
111 | existing->data[OPT_LEN] + length + 2); | ||
112 | memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); | ||
113 | existing->data[OPT_LEN] += length; | ||
114 | } /* else, ignore the data, we could put this in a second option in the future */ | ||
115 | } /* else, ignore the new data */ | ||
116 | } else { | ||
117 | DEBUG("Attaching option %s to list", option->name); | 106 | DEBUG("Attaching option %s to list", option->name); |
118 | 107 | ||
119 | /* make a new option */ | 108 | /* make a new option */ |
@@ -129,7 +118,26 @@ static void attach_option(struct option_set **opt_list, | |||
129 | 118 | ||
130 | new->next = *curr; | 119 | new->next = *curr; |
131 | *curr = new; | 120 | *curr = new; |
121 | return; | ||
132 | } | 122 | } |
123 | |||
124 | /* add it to an existing option */ | ||
125 | DEBUG("Attaching option %s to existing member of list", option->name); | ||
126 | if (option->flags & OPTION_LIST) { | ||
127 | if (existing->data[OPT_LEN] + length <= 255) { | ||
128 | existing->data = xrealloc(existing->data, | ||
129 | existing->data[OPT_LEN] + length + 3); | ||
130 | if ((option->flags & TYPE_MASK) == OPTION_STRING) { | ||
131 | if (existing->data[OPT_LEN] + length >= 255) | ||
132 | return; | ||
133 | /* add space separator between STRING options in a list */ | ||
134 | existing->data[existing->data[OPT_LEN] + 2] = ' '; | ||
135 | existing->data[OPT_LEN]++; | ||
136 | } | ||
137 | memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); | ||
138 | existing->data[OPT_LEN] += length; | ||
139 | } /* else, ignore the data, we could put this in a second option in the future */ | ||
140 | } /* else, ignore the new data */ | ||
133 | } | 141 | } |
134 | 142 | ||
135 | 143 | ||