Skip to content

Commit 2f9b963

Browse files
committed
Make --max-alloc=0 safer.
Always do size checking in my_alloc(), even for `--max-alloc=0`.
1 parent 3476cae commit 2f9b963

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

options.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,8 @@ int parse_arguments(int *argc_p, const char ***argv_p)
19461946
goto cleanup;
19471947
max_alloc = size;
19481948
}
1949+
if (!max_alloc)
1950+
max_alloc = SIZE_MAX;
19491951

19501952
if (old_style_args < 0) {
19511953
if (!am_server && protect_args <= 0 && (arg = getenv("RSYNC_OLD_ARGS")) != NULL && *arg) {

rsync.1.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2106,7 +2106,8 @@ expand it.
21062106
See the [`--max-size`](#opt) option for a description of how SIZE can be
21072107
specified. The default suffix if none is given is bytes.
21082108

2109-
Beginning in 3.2.3, a value of 0 specifies no limit.
2109+
Beginning in 3.2.7, a value of 0 is an easy way to specify SIZE_MAX (the
2110+
largest limit possible).
21102111

21112112
You can set a default value using the environment variable
21122113
[`RSYNC_MAX_ALLOC`](#) using the same SIZE values as supported by this

util2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int msleep(int t)
7272

7373
void *my_alloc(void *ptr, size_t num, size_t size, const char *file, int line)
7474
{
75-
if (max_alloc && num >= max_alloc/size) {
75+
if (num >= max_alloc/size) {
7676
if (!file)
7777
return NULL;
7878
rprintf(FERROR, "[%s] exceeded --max-alloc=%s setting (file=%s, line=%d)\n",

0 commit comments

Comments
 (0)