]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
resolv: Avoid GCC 12 false positive warning [BZ #28439].
authorMartin Sebor <msebor@redhat.com>
Mon, 11 Oct 2021 15:36:57 +0000 (09:36 -0600)
committerMartin Sebor <msebor@redhat.com>
Mon, 11 Oct 2021 15:36:57 +0000 (09:36 -0600)
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.

resolv/res_query.c

index 75b0e5f2f7b51eb2c2c3ce4c12102651a9832ab1..5d0a68dc81fdd8c7545780af6b983fb9fab31e51 100644 (file)
@@ -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,