diff options
author | Elliott Hughes <enh@google.com> | 2024-01-26 09:25:45 -0800 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2024-01-26 17:44:53 -0600 |
commit | 1e04fb285c3c09c4ddb38a89368ca5e7c17c3e88 (patch) | |
tree | 650afc4148ef55d145fd2d7d021e2e8fd2a243db | |
parent | 1e4362ba3f85879eb3b8affd534d61f2f91ad5ef (diff) | |
download | toybox-1e04fb285c3c09c4ddb38a89368ca5e7c17c3e88.tar.gz |
memeater: fixes.
The ULONG_MAX turns into -1 here, which isn't what was intended.
I'll avoid the bikeshed of the least worst full fix and take half
the range which is plenty for my purposes.
Also fix the array indexing to not segfault.
-rw-r--r-- | toys/other/memeater.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/toys/other/memeater.c b/toys/other/memeater.c index f2523c0e..17a3a4c3 100644 --- a/toys/other/memeater.c +++ b/toys/other/memeater.c @@ -20,12 +20,12 @@ config MEMEATER void memeater_main(void) { - unsigned long size = atolx_range(*toys.optargs, 0, ULONG_MAX), i, + unsigned long size = atolx_range(*toys.optargs, 0, LONG_MAX), i, *p = xmalloc(size); // Lock and dirty the physical pages. if (!FLAG(M) && mlock(p, size)) perror_exit("mlock"); - for (i = 0; i<size; i += 4096/sizeof(long)) p[i] = i; + for (i = 0; i<size; i += 4096) p[i/sizeof(long)] = i; while (1) pause(); } |