git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/18] snprintf cleanups
@ 2017-03-28 19:42 Jeff King
  2017-03-28 19:45 ` [PATCH 01/18] do not check odb_mkstemp return value for errors Jeff King
                   ` (19 more replies)
  0 siblings, 20 replies; 30+ messages in thread
From: Jeff King @ 2017-03-28 19:42 UTC (permalink / raw)
  To: git

Our code base calls snprintf() into a fixed-size buffer in a bunch of
places. Sometimes we check the result, and sometimes we accept a silent
truncation. In some cases an overflow is easy given long input. In some
cases it's impossible. And in some cases it depends on how big PATH_MAX
is on your filesystem, and whether it's actually enforced. :)

This series attempts to give more predictable and consistent results by
removing arbitrary buffer limitations. It also tries to make further
audits of snprintf() easier by converting to xsnprintf() where
appropriate.

There are still some snprintf() calls left after this. A few are in code
that's in flux, or is being cleaned up in nearby series (several of my
recent cleanup series were split off from this). A few should probably
remain (e.g., git-daemon will refuse to consider a repo name larger than
PATH_MAX, which may be a reasonable defense against weird memory tricks.
I wouldn't be sad to see this turned into a strbuf with an explicit
length policy enforced separately, though). And there were a few that I
just didn't get around to converting (the dumb-http walker, for example,
but I think it may need a pretty involved audit overall).

It's a lot of patches, but hopefully they're all pretty straightforward
to read.

  [01/18]: do not check odb_mkstemp return value for errors
  [02/18]: odb_mkstemp: write filename into strbuf
  [03/18]: odb_mkstemp: use git_path_buf
  [04/18]: diff: avoid fixed-size buffer for patch-ids
  [05/18]: tag: use strbuf to format tag header
  [06/18]: fetch: use heap buffer to format reflog
  [07/18]: avoid using fixed PATH_MAX buffers for refs
  [08/18]: avoid using mksnpath for refs
  [09/18]: create_branch: move msg setup closer to point of use
  [10/18]: create_branch: use xstrfmt for reflog message
  [11/18]: name-rev: replace static buffer with strbuf
  [12/18]: receive-pack: print --pack-header directly into argv array
  [13/18]: replace unchecked snprintf calls with heap buffers
  [14/18]: combine-diff: replace malloc/snprintf with xstrfmt
  [15/18]: convert unchecked snprintf into xsnprintf
  [16/18]: transport-helper: replace checked snprintf with xsnprintf
  [17/18]: gc: replace local buffer with git_path
  [18/18]: daemon: use an argv_array to exec children

 bisect.c               |  8 +++++---
 branch.c               | 16 ++++++++--------
 builtin/checkout.c     |  5 ++---
 builtin/fetch.c        |  6 ++++--
 builtin/gc.c           |  8 +-------
 builtin/index-pack.c   | 22 ++++++++++++----------
 builtin/ls-remote.c    | 10 ++++++----
 builtin/name-rev.c     | 21 ++++++++++++---------
 builtin/notes.c        |  9 ++++-----
 builtin/receive-pack.c | 17 ++++++++++-------
 builtin/replace.c      | 50 +++++++++++++++++++++++++++-----------------------
 builtin/rev-parse.c    |  5 +++--
 builtin/tag.c          | 42 ++++++++++++++++++------------------------
 cache.h                |  7 +++++--
 combine-diff.c         |  7 ++++---
 daemon.c               | 38 +++++++++++++++++---------------------
 diff.c                 | 20 +++++++++++++-------
 environment.c          | 14 ++++++--------
 fast-import.c          |  9 +++++----
 grep.c                 |  4 ++--
 http.c                 | 10 +++++-----
 imap-send.c            |  2 +-
 pack-bitmap-write.c    | 14 +++++++-------
 pack-write.c           | 16 ++++++++--------
 refs.c                 | 44 ++++++++++++++++++++++++++------------------
 sha1_file.c            |  4 ++--
 submodule.c            |  2 +-
 transport-helper.c     |  5 +----
 28 files changed, 215 insertions(+), 200 deletions(-)

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2017-04-18  4:55 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-28 19:42 [PATCH 0/18] snprintf cleanups Jeff King
2017-03-28 19:45 ` [PATCH 01/18] do not check odb_mkstemp return value for errors Jeff King
2017-03-28 19:45 ` [PATCH 02/18] odb_mkstemp: write filename into strbuf Jeff King
2017-03-28 19:45 ` [PATCH 03/18] odb_mkstemp: use git_path_buf Jeff King
2017-03-28 19:46 ` [PATCH 04/18] diff: avoid fixed-size buffer for patch-ids Jeff King
2017-03-28 19:50   ` Jeff King
2017-03-28 19:46 ` [PATCH 05/18] tag: use strbuf to format tag header Jeff King
2017-03-28 19:46 ` [PATCH 06/18] fetch: use heap buffer to format reflog Jeff King
2017-03-28 19:46 ` [PATCH 07/18] avoid using fixed PATH_MAX buffers for refs Jeff King
2017-04-17  6:00   ` Junio C Hamano
2017-04-18  3:18     ` Jeff King
2017-04-18  4:55       ` Junio C Hamano
2017-03-28 19:46 ` [PATCH 08/18] avoid using mksnpath " Jeff King
2017-03-28 19:46 ` [PATCH 09/18] create_branch: move msg setup closer to point of use Jeff King
2017-03-28 19:46 ` [PATCH 10/18] create_branch: use xstrfmt for reflog message Jeff King
2017-03-28 19:46 ` [PATCH 11/18] name-rev: replace static buffer with strbuf Jeff King
2017-03-28 19:46 ` [PATCH 12/18] receive-pack: print --pack-header directly into argv array Jeff King
2017-03-28 19:46 ` [PATCH 13/18] replace unchecked snprintf calls with heap buffers Jeff King
2017-03-28 19:46 ` [PATCH 14/18] combine-diff: replace malloc/snprintf with xstrfmt Jeff King
2017-03-28 19:46 ` [PATCH 15/18] convert unchecked snprintf into xsnprintf Jeff King
2017-03-28 19:47 ` [PATCH 16/18] transport-helper: replace checked snprintf with xsnprintf Jeff King
2017-03-28 19:47 ` [PATCH 17/18] gc: replace local buffer with git_path Jeff King
2017-03-28 19:48 ` [PATCH 18/18] daemon: use an argv_array to exec children Jeff King
2017-03-28 22:33 ` [PATCH 0/18] snprintf cleanups Junio C Hamano
2017-03-29  3:41   ` Jeff King
2017-03-29 16:05     ` Junio C Hamano
2017-03-30  6:27       ` Jeff King
2017-03-30 17:24         ` Junio C Hamano
2017-03-30 18:26           ` Jeff King
2017-03-29  7:10 ` [PATCH] Makefile: detect errors in running spatch Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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).