summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-05-29 09:11:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-29 18:04:30 (GMT)
commit7f125ff9094bfebbb381afa19380943a088c8fcb (patch)
treed99d5e91f336b3f4cca6120bd54ba89ef159d0a5
parented88148674502893790bf13d70154c157a489a6b (diff)
downloadgit-7f125ff9094bfebbb381afa19380943a088c8fcb.zip
git-7f125ff9094bfebbb381afa19380943a088c8fcb.tar.gz
git-7f125ff9094bfebbb381afa19380943a088c8fcb.tar.bz2
diff-parseopt: correct variable types that are used by parseopt
Most number-related OPT_ macros store the value in an 'int' variable. Many of the variables in 'struct diff_options' have a different type, but during the conversion to using parse_options() I failed to notice and correct. The problem was reported on s360x which is a big-endian architechture. The variable to store '-w' option in this case is xdl_opts, 'long' type, 8 bytes. But since parse_options() assumes 'int' (4 bytes), it will store bits in the wrong part of xdl_opts. The problem was found on little-endian platforms because parse_options() will accidentally store at the right part of xdl_opts. There aren't much to say about the type change (except that 'int' for xdl_opts should still be big enough, since Windows' long is the same size as 'int' and nobody has complained so far). Some safety checks may be implemented in the future to prevent class of bugs. Reported-by: Todd Zullinger <tmz@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--diff.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/diff.h b/diff.h
index d9ad73f..7b66bf1 100644
--- a/diff.h
+++ b/diff.h
@@ -169,7 +169,7 @@ struct diff_options {
const char *prefix;
int prefix_length;
const char *stat_sep;
- long xdl_opts;
+ int xdl_opts;
/* see Documentation/diff-options.txt */
char **anchors;