diff options
author | Jeff King <peff@peff.net> | 2017-03-30 06:35:50 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-03-30 13:02:16 -0700 |
commit | 0730dd4ffb39358f30b1a956cd9182aed1958b47 (patch) | |
tree | 012b6a3e17e64a9a98e8031eeb72e20b2a44773b /Documentation/docbook-xsl.css | |
parent | difftool: handle modified symlinks in dir-diff mode (diff) | |
download | tgif-0730dd4ffb39358f30b1a956cd9182aed1958b47.tar.xz |
difftool: avoid strcpy
In order to checkout files, difftool reads "diff --raw"
output and feeds the names to checkout_entry(). That
function requires us to have a "struct cache_entry". And
because that struct uses a FLEX_ARRAY for the name field, we
have to actually copy in our new name.
The current code allocates a single re-usable cache_entry
that can hold a name up to PATH_MAX, and then copies
filenames into it using strcpy(). But there's no guarantee
that incoming names are smaller than PATH_MAX. They've come
from "diff --raw" output which might be diffing between two
trees (and hence we'd be subject to the PATH_MAX of some
other system, or even none at all if they were created
directly via "update-index").
We can fix this by using make_cache_entry() to create a
correctly-sized cache_entry for each name. This incurs an
extra allocation per file, but this is negligible compared
to actually writing out the file contents.
To make this simpler, we can push this procedure into a new
helper function. Note that we can also get rid of the "len"
variables for src_path and dst_path (and in fact we must, as
the compiler complains that they are unused).
Signed-off-by: Jeff King <peff@peff.net>
Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/docbook-xsl.css')
0 files changed, 0 insertions, 0 deletions