public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] resolv: Avoid GCC 12 false positive warning [BZ #28439].
@ 2021-10-11 15:41 Martin Sebor
  0 siblings, 0 replies; only message in thread
From: Martin Sebor @ 2021-10-11 15:41 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=eb73b87897798de981dbbf019aa957045d768adb

commit eb73b87897798de981dbbf019aa957045d768adb
Author: Martin Sebor <msebor@redhat.com>
Date:   Mon Oct 11 09:36:57 2021 -0600

    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.

Diff:
---
 resolv/res_query.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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,


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-11 15:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 15:41 [glibc] resolv: Avoid GCC 12 false positive warning [BZ #28439] Martin Sebor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).