diff --git a/hddemux.c b/hddemux.c
index e2a3ed4cb3b45d941f7fbbeeed39e02a01639e16..f616cef02bd8552afa013145cbb8b7aef627f183 100644
--- a/hddemux.c
+++ b/hddemux.c
@@ -167,7 +167,11 @@ static void dump_addrinfo(FILE *f, const char *label, const struct addrinfo *a,
   if (ia) {
     if (inet_ntop(a->ai_family, ia, paddr, sizeof(paddr)) == NULL) {
       int e = errno;
-      strerror_r(e, paddr+6, sizeof(paddr)-(6+1));
+      /* these shenanigans are all for the GNU variant of
+         strerror_r(3), not the XSI variant: */
+      const char * e2 = strerror_r(e, paddr+6, sizeof(paddr)-(6+1));
+      if (e2 != paddr+6)
+        strncpy(paddr+6, e2, sizeof(paddr)-(6+1));
       memcpy(paddr, "<err> ", 6);
       paddr[sizeof(paddr)-1] = '\0';
     }