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
ec73881a
Unverified
Commit
ec73881a
authored
Feb 27, 2020
by
Salvatore Sanfilippo
Committed by
GitHub
Feb 27, 2020
Browse files
Merge pull request #6778 from pponnuvel/fix_possible_overflow
Fix a potential overflow with strncpy
parents
d8ab7e80
1d4ea00d
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/config.c
View file @
ec73881a
...
@@ -108,12 +108,12 @@ clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_OBUF_COUNT] = {
...
@@ -108,12 +108,12 @@ clientBufferLimitsConfig clientBufferLimitsDefaults[CLIENT_TYPE_OBUF_COUNT] = {
/* Generic config infrastructure function pointers
/* Generic config infrastructure function pointers
* int is_valid_fn(val, err)
* int is_valid_fn(val, err)
* Return 1 when val is valid, and 0 when invalid.
* Return 1 when val is valid, and 0 when invalid.
* Option
s
lly set err to a static error string.
* Option
a
lly set err to a static error string.
* int update_fn(val, prev, err)
* int update_fn(val, prev, err)
* This function is called only for CONFIG SET command (not at config file parsing)
* This function is called only for CONFIG SET command (not at config file parsing)
* It is called after the actual config is applied,
* It is called after the actual config is applied,
* Return 1 for success, and 0 for failure.
* Return 1 for success, and 0 for failure.
* Option
s
lly set err to a static error string.
* Option
a
lly set err to a static error string.
* On failure the config change will be reverted.
* On failure the config change will be reverted.
*/
*/
...
@@ -729,7 +729,7 @@ void configSetCommand(client *c) {
...
@@ -729,7 +729,7 @@ void configSetCommand(client *c) {
* config_set_memory_field(name,var) */
* config_set_memory_field(name,var) */
}
config_set_memory_field
(
}
config_set_memory_field
(
"client-query-buffer-limit"
,
server
.
client_max_querybuf_len
)
{
"client-query-buffer-limit"
,
server
.
client_max_querybuf_len
)
{
/* Everyhing else is an error... */
/* Every
t
hing else is an error... */
}
config_set_else
{
}
config_set_else
{
addReplyErrorFormat
(
c
,
"Unsupported CONFIG parameter: %s"
,
addReplyErrorFormat
(
c
,
"Unsupported CONFIG parameter: %s"
,
(
char
*
)
c
->
argv
[
2
]
->
ptr
);
(
char
*
)
c
->
argv
[
2
]
->
ptr
);
...
@@ -1673,9 +1673,9 @@ static int enumConfigSet(typeData data, sds value, int update, char **err) {
...
@@ -1673,9 +1673,9 @@ static int enumConfigSet(typeData data, sds value, int update, char **err) {
enumerr
[
sdslen
(
enumerr
)
-
2
]
=
'\0'
;
enumerr
[
sdslen
(
enumerr
)
-
2
]
=
'\0'
;
/* Make sure we don't overrun the fixed buffer */
enumerr
[
LOADBUF_SIZE
-
1
]
=
'\0'
;
strncpy
(
loadbuf
,
enumerr
,
LOADBUF_SIZE
);
strncpy
(
loadbuf
,
enumerr
,
LOADBUF_SIZE
);
/* strncpy does not if null terminate if source string length is >= destination buffer. */
loadbuf
[
LOADBUF_SIZE
-
1
]
=
'\0'
;
sdsfree
(
enumerr
);
sdsfree
(
enumerr
);
*
err
=
loadbuf
;
*
err
=
loadbuf
;
...
...
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