From 82ba5b59d9bc9f1656ea74cfaf3e4c6326957f2b Mon Sep 17 00:00:00 2001 From: Xinchen Hui Date: Tue, 2 Aug 2016 20:28:42 +0800 Subject: [PATCH] =?utf8?q?Fixed=20warning:=20"operation=20on=20=E2=80=98s?= =?utf8?q?=E2=80=99=20may=20be=20undefined"?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ext/standard/crypt.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/standard/crypt.c b/ext/standard/crypt.c index 9e097ca6cf..f2f778e764 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 { -- 2.50.1