com php-src: Fixed warning: "operation on ‘s’ may be undefined": ext/standard/crypt.c
| From: | Xinchen Hui | Date: | Tue, 02 Aug 2016 12:28:42 +0000 |
| Subject: | com php-src: Fixed warning: "operation on ‘s’ may be undefined": ext/standard/crypt.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-93525@lists.php.net to get a copy of this message | ||
Commit: 82ba5b59d9bc9f1656ea74cfaf3e4c6326957f2b
Author: Xinchen Hui <laruence@gmail.com> Tue, 2 Aug 2016 20:28:42 +0800
Parents: 81a7d528148f131a7c38c9c1f1d73ec95a0d6a3c
Branches: PHP-7.1 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=82ba5b59d9bc9f1656ea74cfaf3e4c6326957f2b
Log:
Fixed warning: "operation on ‘s’ may be undefined"
Changed paths:
M ext/standard/crypt.c
Diff:
diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c
index 9e097ca..f2f778e 100644
--- a/ext/standard/crypt.c
+++ b/ext/standard/crypt.c
@@ -99,7 +99,8 @@ static unsigned char itoa64[] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghi
static void php_to64(char *s, int n) /* {{{ */
{
while (--n >= 0) {
- *s++ = itoa64[*s&0x3f];
+ *s = itoa64[*s & 0x3f];
+ s++;
}
}
/* }}} */
@@ -244,16 +245,16 @@ PHP_FUNCTION(crypt)
size_t str_len, salt_in_len = 0;
zend_string *result;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &str, &str_len, &salt_in,
&salt_in_len) == FAILURE) {
+ return;
+ }
+
salt[0] = salt[PHP_MAX_SALT_LEN] = '\0';
/* This will produce suitable results if people depend on DES-encryption
* available (passing always 2-character salt). At least for glibc6.1 */
memset(&salt[1], '$', PHP_MAX_SALT_LEN - 1);
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|s", &str, &str_len, &salt_in,
&salt_in_len) == FAILURE) {
- return;
- }
-
if (salt_in) {
memcpy(salt, salt_in, MIN(PHP_MAX_SALT_LEN, salt_in_len));
} else {