diff options
author | Jeff King <peff@peff.net> | 2018-08-23 02:50:51 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-23 19:08:51 +0200 |
commit | 66e83d9b41f7438cb167b9bb54093ebbf0532437 (patch) | |
tree | e3523c7d6fe3a8e0030357750f3416b487dd588b /sequencer.c | |
parent | sequencer: ignore "---" divider when parsing trailers (diff) | |
download | git-66e83d9b41f7438cb167b9bb54093ebbf0532437.tar.xz git-66e83d9b41f7438cb167b9bb54093ebbf0532437.zip |
append_signoff: use size_t for string offsets
The append_signoff() function takes an "int" to specify the
number of bytes to ignore. Most callers just pass 0, and the
remainder use ignore_non_trailer() to skip over cruft.
That function also returns an int, and uses them internally.
On systems where size_t is larger than an int (i.e., most
64-bit systems), dealing with a ridiculously large commit
message could end up overflowing an int, producing
surprising results (e.g., returning a negative offset, which
would cause us to look outside the original string).
Let's consistently use size_t for these offsets through this
whole stack. As a bonus, this makes the meaning of
"ignore_footer" as an offset (and not a boolean) more clear.
But while we're here, let's also document the interface.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sequencer.c')
-rw-r--r-- | sequencer.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/sequencer.c b/sequencer.c index 51ef7245b1..f24d6c3597 100644 --- a/sequencer.c +++ b/sequencer.c @@ -222,7 +222,7 @@ static const char *get_todo_path(const struct replay_opts *opts) * Returns 3 when sob exists within conforming footer as last entry */ static int has_conforming_footer(struct strbuf *sb, struct strbuf *sob, - int ignore_footer) + size_t ignore_footer) { struct process_trailer_options opts = PROCESS_TRAILER_OPTIONS_INIT; struct trailer_info info; @@ -3660,7 +3660,7 @@ int sequencer_pick_revisions(struct replay_opts *opts) return res; } -void append_signoff(struct strbuf *msgbuf, int ignore_footer, unsigned flag) +void append_signoff(struct strbuf *msgbuf, size_t ignore_footer, unsigned flag) { unsigned no_dup_sob = flag & APPEND_SIGNOFF_DEDUP; struct strbuf sob = STRBUF_INIT; |