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
b483cc50
Commit
b483cc50
authored
Oct 02, 2024
by
Oran Agra
Browse files
Fix lua bit.tohex (CVE-2024-31449)
INT_MIN value must be explicitly checked, and cannot be negated.
parent
c9d29f6a
Changes
2
Hide whitespace changes
Inline
Side-by-side
deps/lua/src/lua_bit.c
View file @
b483cc50
...
...
@@ -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 @
b483cc50
...
...
@@ -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