mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
parse-options: add precision handling for OPTION_BITOP
Similar to 09705696f7 (parse-options: introduce precision handling for
`OPTION_INTEGER`, 2025-04-17) support value variables of different sizes
for OPTION_BITOP. Do that by requiring their "precision" to be set,
casting their "value" pointer accordingly and checking whether the value
fits.
Check if "devfal" fits into an integer variable with the given
"precision", but don't check "extra", as its value is only used to clear
bits, so cannot lead to an overflow. Not checking continues to allow
e.g., using -1 to clear all bits even if the value variable has a
narrower type than intptr_t.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
feeebbf1b7
commit
1d918bf2a5
@@ -240,6 +240,7 @@ struct option {
|
||||
.short_name = (s), \
|
||||
.long_name = (l), \
|
||||
.value = (v), \
|
||||
.precision = sizeof(*v), \
|
||||
.help = (h), \
|
||||
.flags = PARSE_OPT_NOARG|PARSE_OPT_NONEG, \
|
||||
.defval = (set), \
|
||||
|
||||
Reference in New Issue
Block a user