Hi Matt,

> -----Original Message-----
> From: Matt Wilmas [mailto:php_li...@realplain.com]
> Sent: Wednesday, August 19, 2015 12:40 AM
> To: Anatol Belski <anatol....@belski.net>; 'Jakub Zelenka' <bu...@php.net>
> Cc: php-...@lists.php.net; 'PHP internals list' <internals@lists.php.net>
> Subject: Re: [PHP-DEV] Re: [PHP-CVS] com php-src: Fix possible overflow in
> openssl_pbkdf2: ext/openssl/openssl.c
> 
> Hi Anatol,
> 
> ----- Original Message -----
> From: "Anatol Belski"
> Sent: Tuesday, August 18, 2015
> 
> > Ok, got the idea now. But sizeof(size_t) is always >
> > sizeof(zend_long). And for signed, still it is simpler and safer to
> > just use an #ifdef around.
> 
> No, == like I said. :-)   OK, just saw your correction (max instead of
> sizeof); but we're never comparing a size_t with zend_long, so it doesn't
matter.
> 
Yeah, I'm just too tired now, too much sizeof :)

> I don't know where you're getting zend_long from anyway.  [U]INT_MAX is an
> int, not zend_long...
> 
> The check in the macro, that the compiler can remove, should be fine in
all cases
> (even if *int* was 64-bit).
> 
> I don't see how it's simpler or safer to use #if.
> 
> But actually, if #if was used, should really be checking SIZE_MAX >
UINT_MAX I
> guess, and ZEND_LONG_MAX > INT_MAX.
> 
> But using sizeof() in the macro definition gives the same result...
> 
On ILP64 platform integer is 64-bit, yes. But that won't differ as that is
64-bit and unsigned (size_t) is always bigger than signed(int, zend_long,
whatever signed). 

Now, what I initially was proposing - on 32-bit, #ifdef away the check about
INT_MAX < some_int, nothing else. Nothing else can be improved in those
checks (size_t > signed (int, zend_long, etc) on the same platform). It is
not a big case over all the core, but some check in the openssl ext, no
global thing here. So a simple practical solution for a concrete case :)

With your function optimization example - yeah, it will most likely be that.
However disputable in a concrete program/build, as it depends on the
optimization algo, on the data source, on the compiler itself. IMHO it is
good we have gcc or vc++, but still #ifdef excludes any interpretation and
is simple. 

Good night

Anatol


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to