[File] [PATCH] Fix setting MAGIC_PARAM_REGEX_MAX
Vsevolod Stakhov
vsevolod at rspamd.com
Wed Dec 12 10:01:51 UTC 2018
On 12/12/2018 02:14, Christos Zoulas wrote:
> On Dec 11, 11:15pm, vsevolod at rspamd.com (Vsevolod Stakhov) wrote:
> -- Subject: Re: [File] [PATCH] Fix setting MAGIC_PARAM_REGEX_MAX
>
> | On 11/12/2018 21:11, Christos Zoulas wrote:
> | > On Dec 11, 8:09pm, vsevolod at rspamd.com (Vsevolod Stakhov) wrote:
> | > -- Subject: Re: [File] [PATCH] Fix setting MAGIC_PARAM_REGEX_MAX
> | >
> | > | Your change looks incorrect I'm afraid. I'd suggest the following one:
> | > | https://github.com/file/file/compare/master...vstakhov:master
> | >
> | > Yes, it is regex_max, not elf_regex_max. Removing the cast though will
> | > produce warnings.
> |
> | I might be wrong, but the cast of (size_t) to (uint16_t) for
> | MAGIC_PARAM_REGEX_MAX does not look right to me. It narrows the values
> | to 65535 bytes which is likely not intended there.
> |
> | I haven't seen any warnings when I removed that (uint16_t) explicit cast
> | on my x86_64 platform. What warnings do you observe there?
>
> You are not compiling with full warnings.
>
> Check the type of regex_max in file.h, then:
>
I have checked it and it is indeed uint16_t.
However, I think it is wrong: it should be `size_t` like `bytes_max`
element. The problem is that in file softmagic.c around line 1286 there
is size_t variable `bytecnt` that is, in turn, compared to uint16_t
limit `regex_max`.
Hence, `regex_max` should also be of size_t type.
More information about the File
mailing list