Subject: Fix segfault when adns_strerror() is called with a value, for which there is no message defined

From: Tomas Hozza <[email-masked]>
Date: Thu, 16 Feb 2017 15:34:23 +0100

Package: adns

Hello.

In Fedora, we are carrying a downstream patch to fix segfault when adns_strerror() is called with a value, for which there is no message defined. You can find more info in https://bugzilla.redhat.com/show_bug.cgi?id=514838

It would be great if you could consider including this change also in the upstream sources. If you have any questions, please reach out to me.

Regards,
Tomas
-- 
Tomas Hozza
Associate Manager, Software Engineering - EMEA ENG Mainstream RHEL

PGP: 1D9F3C2D
UTC+1 (CET)
Red Hat Inc.                 http://cz.redhat.com
diff --git a/src/general.c b/src/general.c
index c4d1f55..bacdd81 100644
--- a/src/general.c
+++ b/src/general.c
@@ -272,6 +272,8 @@ static const struct sinfo {
   SINFO( nodata,              "No such data"                                 )
 };
 
+static const char *unknown_error_str = "unknown error code";
+
 static int si_compar(const void *key, const void *elem) {
   const adns_status *st= key;
   const struct sinfo *si= elem;
@@ -288,7 +290,7 @@ const char *adns_strerror(adns_status st) {
   const struct sinfo *si;
 
   si= findsinfo(st);
-  return si->string;
+  return (si == NULL) ? unknown_error_str : si->string;
 }
 
 const char *adns_errabbrev(adns_status st) {