[alpine-aports] [PATCH] dhcpcd - Describe dhcp6 error code if no text present
Export this patch
Patch from upstream, will be included in dhcpcd-6.9.4 when released
http://roy.marples.name/projects/dhcpcd/vpatch?from=d8f8999d1efb4376c29d7d2c13b0de1c6da52226&to=90e878f68804cb98e03e90b33233e607e6541358
---
main/dhcpcd/describe_dhcp6_error_code.patch | 77 +++++++++++++++++++++++++++++
1 file changed, 77 insertions(+)
create mode 100644 main/dhcpcd/describe_dhcp6_error_code.patch
diff --git a/main/dhcpcd/describe_dhcp6_error_code.patch b/main/dhcpcd/describe_dhcp6_error_code.patch
new file mode 100644
index 0000000..cd72206
--- /dev/null
+++ b/main/dhcpcd/describe_dhcp6_error_code.patch
@@ -0,0 +1,77 @@
+--- ./dhcp6.c
++++ ./dhcp6.c
+@@ -111,11 +111,12 @@
+ "Success",
+ "Unspecified Failure",
+ "No Addresses Available",
+ "No Binding",
+ "Not On Link",
+- "Use Multicast"
++ "Use Multicast",
++ "No Prefix Available"
+ };
+
+ struct dhcp6_ia_addr {
+ struct in6_addr addr;
+ uint32_t pltime;
+@@ -1660,11 +1661,12 @@
+ dhcp6_checkstatusok(const struct interface *ifp,
+ const struct dhcp6_message *m, const uint8_t *p, size_t len)
+ {
+ const struct dhcp6_option *o;
+ uint16_t code;
+- char *status;
++ char buf[32], *sbuf;
++ const char *status;
+
+ if (p)
+ o = dhcp6_findoption(D6_OPTION_STATUS_CODE, p, len);
+ else
+ o = dhcp6_getmoption(D6_OPTION_STATUS_CODE, m, len);
+@@ -1686,28 +1688,29 @@
+ return 1;
+
+ len -= sizeof(code);
+
+ if (len == 0) {
+- if (code < sizeof(dhcp6_statuses) / sizeof(char *)) {
+- p = (const uint8_t *)dhcp6_statuses[code];
+- len = strlen((const char *)p);
+- } else
+- p = NULL;
+- } else
+- p += sizeof(code);
++ sbuf = NULL;
++ if (code < sizeof(dhcp6_statuses) / sizeof(char *))
++ status = dhcp6_statuses[code];
++ else {
++ snprintf(buf, sizeof(buf), "Unknown Status (%d)", code);
++ status = buf;
++ }
++ } else {
++ if ((sbuf = malloc(len + 1)) == NULL) {
++ logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
++ return -1;
++ }
++ memcpy(sbuf, p + sizeof(code), len);
++ sbuf[len] = '\0';
++ status = sbuf;
++ }
+
+- status = malloc(len + 1);
+- if (status == NULL) {
+- logger(ifp->ctx, LOG_ERR, "%s: %m", __func__);
+- return -1;
+- }
+- if (p)
+- memcpy(status, p, len);
+- status[len] = '\0';
+ logger(ifp->ctx, LOG_ERR, "%s: DHCPv6 REPLY: %s", ifp->name, status);
+- free(status);
++ free(sbuf);
+ return -1;
+ }
+
+ const struct ipv6_addr *
+ dhcp6_iffindaddr(const struct interface *ifp, const struct in6_addr *addr,
+
--
2.4.1
---
Unsubscribe: alpine-aports+unsubscribe@lists.alpinelinux.org
Help: alpine-aports+help@lists.alpinelinux.org
---