summaryrefslogtreecommitdiff
path: root/src/script.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2016-01-28 20:06:46 +0100
committerSteven Barth <steven@midlink.org>2016-01-28 20:06:46 +0100
commit51541450f9970075f2e8a7d6112336e1cf93ab10 (patch)
tree60c9bb30db4d27cdb0a29599e653bb4661d3dbc3 /src/script.c
parent23aa0c218808361c1252b73a8ba82a91ac9039e7 (diff)
parentd277ddb78abd034eb0e1c088ac969cdeef10d9e2 (diff)
downloadodhcp6c-51541450f9970075f2e8a7d6112336e1cf93ab10.tar.gz
Merge pull request #42 from bwhacks/logic-fixes
Logic fixes
Diffstat (limited to 'src/script.c')
-rw-r--r--src/script.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/script.c b/src/script.c
index 3579331..1533510 100644
--- a/src/script.c
+++ b/src/script.c
@@ -105,7 +105,9 @@ static void ipv6_to_env(const char *name,
buf_len += strlen(&buf[buf_len]);
buf[buf_len++] = ' ';
}
- buf[buf_len - 1] = '\0';
+ if (buf[buf_len - 1] == ' ')
+ buf_len--;
+ buf[buf_len] = '\0';
putenv(buf);
}
@@ -126,7 +128,9 @@ static void fqdn_to_env(const char *name, const uint8_t *fqdn, size_t len)
buf_len += strlen(&buf[buf_len]);
buf[buf_len++] = ' ';
}
- buf[buf_len - 1] = '\0';
+ if (buf[buf_len - 1] == ' ')
+ buf_len--;
+ buf[buf_len] = '\0';
putenv(buf);
}
@@ -201,7 +205,9 @@ static void entry_to_env(const char *name, const void *data, size_t len, enum en
buf[buf_len++] = ' ';
}
- buf[buf_len - 1] = '\0';
+ if (buf[buf_len - 1] == ' ')
+ buf_len--;
+ buf[buf_len] = '\0';
putenv(buf);
}
@@ -220,7 +226,9 @@ static void search_to_env(const char *name, const uint8_t *start, size_t len)
*c++ = ' ';
}
- c[-1] = '\0';
+ if (c[-1] == ' ')
+ c--;
+ *c = '\0';
putenv(buf);
}