]> git.ipfire.org Git - thirdparty/git.git/commit - setup.c
replace trivial malloc + sprintf / strcpy calls with xstrfmt
authorJeff King <peff@peff.net>
Thu, 24 Sep 2015 21:07:03 +0000 (17:07 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Sep 2015 17:18:18 +0000 (10:18 -0700)
commit75faa45ae0230b321bf72027b2274315d7e14e34
tree3b4aa1b362078ba4db498a087f3330ffe7affbd8
parentb7115a350b5c01ce0ae7a8735e4235d4b2367b5f
replace trivial malloc + sprintf / strcpy calls with xstrfmt

It's a common pattern to do:

  foo = xmalloc(strlen(one) + strlen(two) + 1 + 1);
  sprintf(foo, "%s %s", one, two);

(or possibly some variant with strcpy()s or a more
complicated length computation).  We can switch these to use
xstrfmt, which is shorter, involves less error-prone manual
computation, and removes many sprintf and strcpy calls which
make it harder to audit the code for real buffer overflows.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/apply.c
builtin/ls-remote.c
builtin/name-rev.c
environment.c
imap-send.c
reflog-walk.c
remote.c
setup.c
unpack-trees.c