diff options
author | Robin Watts <Robin.Watts@artifex.com> | 2020-07-08 18:52:44 +0100 |
---|---|---|
committer | Robin Watts <Robin.Watts@artifex.com> | 2020-07-08 19:05:29 +0100 |
commit | cc596ad6dd030f192416086370bd54e8059589d4 (patch) | |
tree | deb5e0ca65de204e1ee0a977dffbc32c0826e7ce /base/mkromfs.c | |
parent | b0c208a555ed89139395a6ed0d8dce70d81cde09 (diff) | |
download | ghostpdl-cc596ad6dd030f192416086370bd54e8059589d4.tar.gz |
lgtm.com issue: Fix potential overflow in mkromfs.
We know that we only ever call this splitting the ROMFS into 4,
so it's never going to overflow, but lgtm.com can't know that.
Add a check to keep the number down to a sane size to keep it
happy.
Diffstat (limited to 'base/mkromfs.c')
-rw-r--r-- | base/mkromfs.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/base/mkromfs.c b/base/mkromfs.c index 49be5afc4..471f6dabf 100644 --- a/base/mkromfs.c +++ b/base/mkromfs.c @@ -521,6 +521,9 @@ static void prepare_splits(split_data *splits) { if (splits->num_splits) { + /* Limit splits->num_splits to something merely insane to avoid overflow. */ + if (splits->num_splits > (1<<(8*sizeof(int)-2))/sizeof(unsigned long)) + splits->num_splits = (1<<(8*sizeof(int)-2))/sizeof(unsigned long); /* Make sure we have a properly sized size array. */ if (splits->num_splits > splits->max_splits) { unsigned long *sizes = realloc(splits->sizes, sizeof(unsigned long) * splits->num_splits); |