aboutsummaryrefslogtreecommitdiff
path: root/networking/udhcp/files.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-02-02 01:16:08 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2007-02-02 01:16:08 +0000
commitc4d606e3678333fe07348904d1e2222cf43c5e31 (patch)
tree927d83d07d37b508ca6d507763c0dbbf0641ee5a /networking/udhcp/files.c
parentde55b5d014ac8800f0e7bfffa9a74d93beec28af (diff)
downloadbusybox-c4d606e3678333fe07348904d1e2222cf43c5e31.tar.gz
udhcpd: allow "domain" to be a list of DNS servers, not just one
Diffstat (limited to 'networking/udhcp/files.c')
-rw-r--r--networking/udhcp/files.c32
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,
{
struct option_set *existing, *new, **curr;
- /* add it to an existing option */
existing = find_option(*opt_list, option->code);
- if (existing) {
- DEBUG("Attaching option %s to existing member of list", option->name);
- if (option->flags & OPTION_LIST) {
- if (existing->data[OPT_LEN] + length <= 255) {
- existing->data = realloc(existing->data,
- existing->data[OPT_LEN] + length + 2);
- memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);
- existing->data[OPT_LEN] += length;
- } /* else, ignore the data, we could put this in a second option in the future */
- } /* else, ignore the new data */
- } else {
+ if (!existing) {
DEBUG("Attaching option %s to list", option->name);
/* make a new option */
@@ -129,7 +118,26 @@ static void attach_option(struct option_set **opt_list,
new->next = *curr;
*curr = new;
+ return;
}
+
+ /* add it to an existing option */
+ DEBUG("Attaching option %s to existing member of list", option->name);
+ if (option->flags & OPTION_LIST) {
+ if (existing->data[OPT_LEN] + length <= 255) {
+ existing->data = xrealloc(existing->data,
+ existing->data[OPT_LEN] + length + 3);
+ if ((option->flags & TYPE_MASK) == OPTION_STRING) {
+ if (existing->data[OPT_LEN] + length >= 255)
+ return;
+ /* add space separator between STRING options in a list */
+ existing->data[existing->data[OPT_LEN] + 2] = ' ';
+ existing->data[OPT_LEN]++;
+ }
+ memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length);
+ existing->data[OPT_LEN] += length;
+ } /* else, ignore the data, we could put this in a second option in the future */
+ } /* else, ignore the new data */
}