about summary refs log tree commit diff
path: root/resolv/res_query.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-10-11 09:36:57 -0600
committerMartin Sebor <msebor@redhat.com>2021-10-11 09:36:57 -0600
commiteb73b87897798de981dbbf019aa957045d768adb (patch)
tree4cc7e81a223836418f367f68b6edb9a781bab0b8 /resolv/res_query.c
parent5d26d12f4ab59c67399c4d5ddcad91704fb737f9 (diff)
downloadglibc-eb73b87897798de981dbbf019aa957045d768adb.tar.gz
glibc-eb73b87897798de981dbbf019aa957045d768adb.tar.xz
glibc-eb73b87897798de981dbbf019aa957045d768adb.zip
resolv: Avoid GCC 12 false positive warning [BZ #28439].
Replace a call to sprintf with an equivalent pair of stpcpy/strcpy calls
to avoid a GCC 12 -Wformat-overflow false positive due to recent optimizer
improvements.
Diffstat (limited to 'resolv/res_query.c')
-rw-r--r--resolv/res_query.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/resolv/res_query.c b/resolv/res_query.c
index 75b0e5f2f7..5d0a68dc81 100644
--- a/resolv/res_query.c
+++ b/resolv/res_query.c
@@ -610,7 +610,9 @@ __res_context_querydomain (struct resolv_context *ctx,
 			RES_SET_H_ERRNO(statp, NO_RECOVERY);
 			return (-1);
 		}
-		sprintf(nbuf, "%s.%s", name, domain);
+		char *p = __stpcpy (nbuf, name);
+		*p++ = '.';
+		strcpy (p, domain);
 	}
 	return __res_context_query (ctx, longname, class, type, answer,
 				    anslen, answerp, answerp2, nanswerp2,