6ca6e8
commit 92d5c52aaac0fa8e58b92e96bf2025d6848a2845
6ca6e8
Author: Martin Sebor <msebor@redhat.com>
6ca6e8
Date:   Mon Oct 11 09:36:57 2021 -0600
6ca6e8
6ca6e8
    resolv: Avoid GCC 12 false positive warning [BZ #28439].
6ca6e8
    
6ca6e8
    Replace a call to sprintf with an equivalent pair of stpcpy/strcpy calls
6ca6e8
    to avoid a GCC 12 -Wformat-overflow false positive due to recent optimizer
6ca6e8
    improvements.
6ca6e8
    
6ca6e8
    (cherry picked from commit eb73b87897798de981dbbf019aa957045d768adb)
6ca6e8
6ca6e8
diff --git a/resolv/res_query.c b/resolv/res_query.c
6ca6e8
index 2f3c28cfc8c0d832..1d2c81737bc889c9 100644
6ca6e8
--- a/resolv/res_query.c
6ca6e8
+++ b/resolv/res_query.c
6ca6e8
@@ -626,7 +626,9 @@ __res_context_querydomain (struct resolv_context *ctx,
6ca6e8
 			RES_SET_H_ERRNO(statp, NO_RECOVERY);
6ca6e8
 			return (-1);
6ca6e8
 		}
6ca6e8
-		sprintf(nbuf, "%s.%s", name, domain);
6ca6e8
+		char *p = __stpcpy (nbuf, name);
6ca6e8
+		*p++ = '.';
6ca6e8
+		strcpy (p, domain);
6ca6e8
 	}
6ca6e8
 	return __res_context_query (ctx, longname, class, type, answer,
6ca6e8
 				    anslen, answerp, answerp2, nanswerp2,