Re: [pcre-dev] undefined behavior in pcre2_compile.c

Kezdőlap
Üzenet törlése
Szerző: ph10
Dátum:  
Címzett: Dingbao Xie
CC: pcre-dev
Tárgy: Re: [pcre-dev] undefined behavior in pcre2_compile.c
On Thu, 14 May 2015, Dingbao Xie wrote:

> Attachment are two files to reproduce the undefined behavior.


<snip>

> src/pcre2_compile.c:6665:45: runtime error: left shift of 1 by 31 places
> cannot be represented in type 'int'


Thank you for reporting this. I am not a C++ user, nor do I have clang
installed, but I was eventually able to reproduce this with gcc, using
the options -fsanitize=undefined -std=c99. I have fixed the issue in
four places (by changing "1 << x" to "1u << x") and I have committed
the patched code (it's now at r267).

The use of -fsanitize=undefined has shown up some other issues in PCRE2,
which I will try to fix shortly. I will then add a compile using this
option to the tests that are done before each release.

Philip

--
Philip Hazel