Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
3a2669e8
Commit
3a2669e8
authored
Oct 02, 2024
by
Oran Agra
Committed by
YaacovHazan
Oct 08, 2024
Browse files
Fix lua bit.tohex (CVE-2024-31449)
INT_MIN value must be explicitly checked, and cannot be negated.
parent
f39e5117
Changes
2
Show whitespace changes
Inline
Side-by-side
deps/lua/src/lua_bit.c
View file @
3a2669e8
...
...
@@ -132,6 +132,7 @@ static int bit_tohex(lua_State *L)
const
char
*
hexdigits
=
"0123456789abcdef"
;
char
buf
[
8
];
int
i
;
if
(
n
==
INT32_MIN
)
n
=
INT32_MIN
+
1
;
if
(
n
<
0
)
{
n
=
-
n
;
hexdigits
=
"0123456789ABCDEF"
;
}
if
(
n
>
8
)
n
=
8
;
for
(
i
=
(
int
)
n
;
--
i
>=
0
;
)
{
buf
[
i
]
=
hexdigits
[
b
&
15
];
b
>>=
4
;
}
...
...
tests/unit/scripting.tcl
View file @
3a2669e8
...
...
@@ -691,6 +691,12 @@ start_server {tags {"scripting"}} {
set e
}
{
ERR *Attempt to modify a readonly table*
}
test
{
lua bit.tohex bug
}
{
set res
[
run_script
{
return bit.tohex
(
65535, -2147483648
)}
0
]
r ping
set res
}
{
0000FFFF
}
test
{
Test an example script DECR_IF_GT
}
{
set decr_if_gt
{
local current
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment