-
Notifications
You must be signed in to change notification settings - Fork 7.8k
ext/standard warning to error promotions #5814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ext/standard/array.c
Outdated
HashTable *ht; | ||
|
||
ZEND_PARSE_PARAMETERS_START(2, 2) | ||
Z_PARAM_ZVAL(key) | ||
Z_PARAM_STR_OR_LONG(string_key, int_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
array_key_exists()
is not a good target for this. Please see Nikita's comment here: #4887
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isset does a usual int silent type cast, string array keys are the only weird thing where "03" will remain "03" but "3" would become the integer index 3
thus I think the behaviour would be consistent but can double check
599506c
to
2ead2f6
Compare
ext/standard/dns.c
Outdated
/* name too long, protect from CVE-2015-0235 */ | ||
php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN); | ||
RETURN_STRINGL(hostname, hostname_len); | ||
zend_argument_value_error(1, "must be less than %d characters", MAXFQDNLEN); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about cannot be longer than %d characters
? As far as I see the condition, less than MAXFQDNLEN
isn't true, because being equal is also okay.
ext/standard/dns.c
Outdated
php_error_docref(NULL, E_WARNING, | ||
"Numeric DNS record type must be between 1 and 65535, '" ZEND_LONG_FMT "' given", type_param); | ||
RETURN_FALSE; | ||
zend_argument_value_error(2, "must be between 1 and 65535 when Argument #5 ($raw) is true"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zend_argument_value_error(2, "must be between 1 and 65535 when Argument #5 ($raw) is true"); | |
zend_argument_value_error(2, "must be between 1 and 65535 when argument #5 ($raw) is true"); |
2ead2f6
to
f9bd96a
Compare
I dropped the array_key_exist one while addressing the reviews |
ext/standard/dns.c
Outdated
php_error_docref(NULL, E_WARNING, "Type '%s' not supported", rectype); | ||
RETURN_FALSE; | ||
zend_argument_value_error(2, "must be one of \"A\", \"NS\", \"MX\", \"PTR\", \"ANY\", \"SAO\", \"CAA\", " | ||
"\"TXT\", \"CNAME\", \"AAAA\", \"SRV\", \"NAPTR\", or \"A6\""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should list all possibilities here, as this may get extended and depends on environment (e.g. I don't think CAA works on Windows). Just say valid DNS record type
or something like that.
ext/standard/dns.c
Outdated
php_error_docref(NULL, E_WARNING, "Type '" ZEND_LONG_FMT "' not supported", type_param); | ||
RETURN_FALSE; | ||
zend_argument_value_error(2, "must be one of DNS_A, DNS_CNAME, DNS_HINFO, DNS_CAA, DNS_MX, " | ||
"DNS_NS, DNS_PTR, DNS_SOA, DNS_TXT, DNS_AAAA, DNS_SRV, DNS_NAPTR, DNS_A6, DNS_ALL, or DNS_ANY"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd only mention DNS_*
here (we do this in a few places).
ext/standard/iptc.c
Outdated
@@ -193,8 +193,8 @@ PHP_FUNCTION(iptcembed) | |||
} | |||
|
|||
if (iptcdata_len >= SIZE_MAX - sizeof(psheader) - 1025) { | |||
php_error_docref(NULL, E_WARNING, "IPTC data too large"); | |||
RETURN_FALSE; | |||
zend_argument_value_error(1, "must be less than %d characters", SIZE_MAX - sizeof(psheader) - 1025); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd go for is too large
here, the exact value doesn't add value as it's impossible to reach with sensible code.
?> | ||
--EXPECT-- | ||
gethostbyname(): Argument #1 ($hostname) cannot be longer than 255 characters | ||
gethostbynamel(): Argument #1 ($hostname) cannot be longer than 255 characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be %d
. Though I'm not really sure if we actually want to promote these. The number differs by platform and is something one could hit with reasonable code. As gethostbyname()
is already fallible, it would currently be a necessary false check.
ext/standard/user_filters.c
Outdated
"Err, filter \"%s\" is not in the user-filter map, but somehow the user-filter-factory was invoked for it!?", filtername); | ||
zend_throw_error(NULL, "Filter \"%s\" is not in the user-filter map, " | ||
"but user-filter-factory was invoked for it." | ||
"This is a bug, please report it at https://bugs.php.net", filtername); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should just ZEND_ASSERT(fdat)
here.
ext/standard/dns.c
Outdated
php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN); | ||
RETURN_STRINGL(hostname, hostname_len); | ||
zend_argument_value_error(1, "cannot be longer than %d characters", MAXFQDNLEN); | ||
RETURN_THROWS(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So compared to gethostbynamel()
, gethostbyname()
does not return false
should I change this to return false if I revert the ValueError to warning?
f9bd96a
to
e477a5d
Compare
e477a5d
to
c0aea24
Compare
Does should be rather uncontroversial I think