[File] [PATCH] Fix setting MAGIC_PARAM_REGEX_MAX

Christos Zoulas christos at zoulas.com
Wed Dec 12 02:14:02 UTC 2018


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:

$ cat x.c
extern long y;
int main(void)
{
    short x = y;
    return x;
}
$ gcc -c -Wconversion x.c
x.c: In function 'int main()':
x.c:4:15: warning: conversion to 'short int' from 'long int' may alter its value [-Wconversion]
     short x = y;

christos


More information about the File mailing list