diff options
-rw-r--r-- | networking/udhcp/domain_codec.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/networking/udhcp/domain_codec.c b/networking/udhcp/domain_codec.c index c1325d8be..05cdf51e9 100644 --- a/networking/udhcp/domain_codec.c +++ b/networking/udhcp/domain_codec.c | |||
@@ -42,7 +42,7 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre) | |||
42 | */ | 42 | */ |
43 | while (1) { | 43 | while (1) { |
44 | /* note: "return NULL" below are leak-safe since | 44 | /* note: "return NULL" below are leak-safe since |
45 | * dst isn't yet allocated */ | 45 | * dst isn't allocated yet */ |
46 | const uint8_t *c; | 46 | const uint8_t *c; |
47 | unsigned crtpos, retpos, depth, len; | 47 | unsigned crtpos, retpos, depth, len; |
48 | 48 | ||
@@ -95,9 +95,8 @@ char* FAST_FUNC dname_dec(const uint8_t *cstr, int clen, const char *pre) | |||
95 | if (!dst) { /* first pass? */ | 95 | if (!dst) { /* first pass? */ |
96 | /* allocate dst buffer and copy pre */ | 96 | /* allocate dst buffer and copy pre */ |
97 | unsigned plen = strlen(pre); | 97 | unsigned plen = strlen(pre); |
98 | ret = dst = xmalloc(plen + len); | 98 | ret = xmalloc(plen + len); |
99 | memcpy(dst, pre, plen); | 99 | dst = stpcpy(ret, pre); |
100 | dst += plen; | ||
101 | } else { | 100 | } else { |
102 | dst[len - 1] = '\0'; | 101 | dst[len - 1] = '\0'; |
103 | break; | 102 | break; |