summaryrefslogtreecommitdiff
path: root/ext/standard/sha1.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/standard/sha1.c')
-rw-r--r--ext/standard/sha1.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/ext/standard/sha1.c b/ext/standard/sha1.c
index 8a05f50416..249828fb3d 100644
--- a/ext/standard/sha1.c
+++ b/ext/standard/sha1.c
@@ -1,6 +1,6 @@
/*
+----------------------------------------------------------------------+
- | PHP Version 5 |
+ | PHP Version 7 |
+----------------------------------------------------------------------+
| Copyright (c) 1997-2014 The PHP Group |
+----------------------------------------------------------------------+
@@ -46,10 +46,10 @@ PHP_FUNCTION(sha1)
sha1str[0] = '\0';
PHP_SHA1Init(&context);
- PHP_SHA1Update(&context, arg->val, arg->len);
+ PHP_SHA1Update(&context, (unsigned char *) arg->val, arg->len);
PHP_SHA1Final(digest, &context);
if (raw_output) {
- RETURN_STRINGL(digest, 20);
+ RETURN_STRINGL((char *) digest, 20);
} else {
make_digest_ex(sha1str, digest, 20);
RETVAL_STRING(sha1str);
@@ -71,7 +71,7 @@ PHP_FUNCTION(sha1_file)
unsigned char buf[1024];
unsigned char digest[20];
PHP_SHA1_CTX context;
- int n;
+ size_t n;
php_stream *stream;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "p|b", &arg, &arg_len, &raw_output) == FAILURE) {
@@ -85,7 +85,7 @@ PHP_FUNCTION(sha1_file)
PHP_SHA1Init(&context);
- while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
+ while ((n = php_stream_read(stream, (char *) buf, sizeof(buf))) > 0) {
PHP_SHA1Update(&context, buf, n);
}
@@ -93,12 +93,8 @@ PHP_FUNCTION(sha1_file)
php_stream_close(stream);
- if (n<0) {
- RETURN_FALSE;
- }
-
if (raw_output) {
- RETURN_STRINGL(digest, 20);
+ RETURN_STRINGL((char *) digest, 20);
} else {
make_digest_ex(sha1str, digest, 20);
RETVAL_STRING(sha1str);