Patch-Source: https://src.fedoraproject.org/rpms/dnsmasq/blob/f36/f/0009-Address-coverity-issues-detected-in-util.c.patch (backport from upstream) -- From 7b975696a7bda5b86fcf168644f177544adb6fe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Fri, 3 Sep 2021 17:38:26 +0200 Subject: [PATCH 09/15] Address coverity issues detected in util.c diff --git a/src/util.c b/src/util.c index 1425764..8e69d55 100644 --- a/src/util.c +++ b/src/util.c @@ -208,6 +208,8 @@ char *canonicalise(char *in, int *nomem) /* older libidn2 strips underscores, so don't do IDN processing if the name has an underscore (check_name() returned 2) */ if (rc != 2) +#else + (void)rc; #endif #if defined(HAVE_IDN) || defined(HAVE_LIBIDN2) { @@ -235,11 +237,14 @@ char *canonicalise(char *in, int *nomem) return ret; } #endif - + +#if !defined(HAVE_LIBIDN2) || (defined(HAVE_LIBIDN2) && (!defined(IDN2_VERSION_NUMBER) || IDN2_VERSION_NUMBER < 0x02000003)) + /* If recent libidn2 is used, it cannot reach this code. */ if ((ret = whine_malloc(strlen(in)+1))) strcpy(ret, in); else if (nomem) - *nomem = 1; + *nomem = 1; +#endif return ret; } @@ -528,7 +533,7 @@ void prettyprint_time(char *buf, unsigned int t) if ((x = (t/60)%60)) p += sprintf(&buf[p], "%um", x); if ((x = t%60)) - p += sprintf(&buf[p], "%us", x); + sprintf(&buf[p], "%us", x); } } @@ -574,7 +579,7 @@ int parse_hex(char *in, unsigned char *out, int maxlen, int j, bytes = (1 + (r - in))/2; for (j = 0; j < bytes; j++) { - char sav = sav; + char sav; if (j < bytes - 1) { sav = in[(j+1)*2]; -- 2.31.1