Skip to content

Commit

Permalink
resolv: Avoid GCC 12 false positive warning [BZ #28439].
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Martin Sebor committed Oct 11, 2021
1 parent 5d26d12 commit eb73b87
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion resolv/res_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit eb73b87

Please sign in to comment.