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.
This commit is contained in:
Martin Sebor 2021-10-11 09:36:57 -06:00
parent 5d26d12f4a
commit eb73b87897

View 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,