Skip to content

Commit

Permalink
Revert "Fix compiler warnings in ext/hash"
Browse files Browse the repository at this point in the history
This reverts commit 596fbf7.
  • Loading branch information
KalleZ committed Oct 3, 2018
1 parent 596fbf7 commit f7991ca
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
30 changes: 15 additions & 15 deletions ext/hash/hash.c
Expand Up @@ -151,11 +151,11 @@ static void php_hash_do_hash(INTERNAL_FUNCTION_PARAMETERS, int isfilename, zend_
size_t n;

while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
ops->hash_update(context, (unsigned char *) buf, (unsigned int) n);
ops->hash_update(context, (unsigned char *) buf, n);
}
php_stream_close(stream);
} else {
ops->hash_update(context, (unsigned char *) data, (unsigned int) data_len);
ops->hash_update(context, (unsigned char *) data, data_len);
}

digest = zend_string_alloc(ops->digest_size, 0);
Expand Down Expand Up @@ -213,7 +213,7 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *
if (key_len > (size_t)ops->block_size) {
/* Reduce the key first */
ops->hash_init(context);
ops->hash_update(context, key, (unsigned int) key_len);
ops->hash_update(context, key, key_len);
ops->hash_final(K, context);
} else {
memcpy(K, key, key_len);
Expand All @@ -225,7 +225,7 @@ static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *
static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const zend_long data_size) {
ops->hash_init(context);
ops->hash_update(context, key, ops->block_size);
ops->hash_update(context, data, (unsigned int) data_size);
ops->hash_update(context, data, data_size);
ops->hash_final(final, context);
}

Expand Down Expand Up @@ -276,11 +276,11 @@ static void php_hash_do_hash_hmac(INTERNAL_FUNCTION_PARAMETERS, int isfilename,

if (isfilename) {
char buf[1024];
size_t n;
int n;
ops->hash_init(context);
ops->hash_update(context, K, ops->block_size);
while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
ops->hash_update(context, (unsigned char *) buf, (unsigned int) n);
ops->hash_update(context, (unsigned char *) buf, n);
}
php_stream_close(stream);
ops->hash_final((unsigned char *) ZSTR_VAL(digest), context);
Expand Down Expand Up @@ -379,7 +379,7 @@ static void php_hashcontext_ctor(INTERNAL_FUNCTION_PARAMETERS, zval *objval) {

if (ZSTR_LEN(key) > (size_t)ops->block_size) {
/* Reduce the key first */
ops->hash_update(context, (unsigned char *) ZSTR_VAL(key), (unsigned int) ZSTR_LEN(key));
ops->hash_update(context, (unsigned char *) ZSTR_VAL(key), ZSTR_LEN(key));
ops->hash_final((unsigned char *) K, context);
/* Make the context ready to start over */
ops->hash_init(context);
Expand Down Expand Up @@ -427,7 +427,7 @@ PHP_FUNCTION(hash_update)

hash = php_hashcontext_from_object(Z_OBJ_P(zhash));
PHP_HASHCONTEXT_VERIFY("hash_update", hash);
hash->ops->hash_update(hash->context, (unsigned char *) ZSTR_VAL(data), (unsigned int) ZSTR_LEN(data));
hash->ops->hash_update(hash->context, (unsigned char *) ZSTR_VAL(data), ZSTR_LEN(data));

RETURN_TRUE;
}
Expand Down Expand Up @@ -462,7 +462,7 @@ PHP_FUNCTION(hash_update_stream)
/* Nada mas */
RETURN_LONG(didread);
}
hash->ops->hash_update(hash->context, (unsigned char *) buf, (unsigned int) n);
hash->ops->hash_update(hash->context, (unsigned char *) buf, n);
length -= n;
didread += n;
}
Expand Down Expand Up @@ -498,7 +498,7 @@ PHP_FUNCTION(hash_update_file)
}

while ((n = php_stream_read(stream, buf, sizeof(buf))) > 0) {
hash->ops->hash_update(hash->context, (unsigned char *) buf, (unsigned int) n);
hash->ops->hash_update(hash->context, (unsigned char *) buf, n);
}
php_stream_close(stream);

Expand Down Expand Up @@ -671,7 +671,7 @@ PHP_FUNCTION(hash_hkdf)
// Expand
returnval = zend_string_alloc(length, 0);
digest = emalloc(ops->digest_size);
for (i = 1, rounds = (int)(length - 1) / ops->digest_size + 1; i <= rounds; i++) {
for (i = 1, rounds = (length - 1) / ops->digest_size + 1; i <= rounds; i++) {
// chr(i)
unsigned char c[1];
c[0] = (i & 0xFF);
Expand All @@ -685,7 +685,7 @@ PHP_FUNCTION(hash_hkdf)
}

if (info != NULL && ZSTR_LEN(info) > 0) {
ops->hash_update(context, (unsigned char *) ZSTR_VAL(info), (unsigned int) ZSTR_LEN(info));
ops->hash_update(context, (unsigned char *) ZSTR_VAL(info), ZSTR_LEN(info));
}

ops->hash_update(context, c, 1);
Expand Down Expand Up @@ -831,7 +831,7 @@ PHP_FUNCTION(hash_pbkdf2)
if (raw_output) {
memcpy(ZSTR_VAL(returnval), result, length);
} else {
php_hash_bin2hex(ZSTR_VAL(returnval), result, (unsigned int) digest_length);
php_hash_bin2hex(ZSTR_VAL(returnval), result, digest_length);
}
ZSTR_VAL(returnval)[length] = 0;
efree(result);
Expand Down Expand Up @@ -1083,8 +1083,8 @@ PHP_FUNCTION(mhash_keygen_s2k)
for (j=0;j<i;j++) {
ops->hash_update(context, &null, 1);
}
ops->hash_update(context, (unsigned char *)padded_salt, (unsigned int) salt_len);
ops->hash_update(context, (unsigned char *)password, (unsigned int) password_len);
ops->hash_update(context, (unsigned char *)padded_salt, salt_len);
ops->hash_update(context, (unsigned char *)password, password_len);
ops->hash_final((unsigned char *)digest, context);
memcpy( &key[i*block_size], digest, block_size);
}
Expand Down
4 changes: 2 additions & 2 deletions ext/hash/hash_gost.c
Expand Up @@ -256,9 +256,9 @@ PHP_HASH_API void PHP_GOSTUpdate(PHP_GOST_CTX *context, const unsigned char *inp
if ((MAX32 - context->count[0]) < (len * 8)) {
context->count[1]++;
context->count[0] = MAX32 - context->count[0];
context->count[0] = (uint32_t)(len * 8) - context->count[0];
context->count[0] = (len * 8) - context->count[0];
} else {
context->count[0] += (uint32_t) (len * 8);
context->count[0] += len * 8;
}

if (context->length + len < 32) {
Expand Down
2 changes: 1 addition & 1 deletion ext/hash/hash_md.c
Expand Up @@ -679,7 +679,7 @@ PHP_HASH_API void PHP_MD2Update(PHP_MD2_CTX *context, const unsigned char *buf,
/* Copy remaining data to buffer */
if (p < e) {
memcpy(context->buffer, p, e - p);
context->in_buffer = (char)(e - p);
context->in_buffer = e - p;
}
}

Expand Down
4 changes: 2 additions & 2 deletions ext/hash/hash_snefru.c
Expand Up @@ -142,9 +142,9 @@ PHP_HASH_API void PHP_SNEFRUUpdate(PHP_SNEFRU_CTX *context, const unsigned char
if ((MAX32 - context->count[1]) < (len * 8)) {
context->count[0]++;
context->count[1] = MAX32 - context->count[1];
context->count[1] = (uint32_t) (len * 8) - context->count[1];
context->count[1] = (len * 8) - context->count[1];
} else {
context->count[1] += (uint32_t) (len * 8);
context->count[1] += len * 8;
}

if (context->length + len < 32) {
Expand Down
4 changes: 2 additions & 2 deletions ext/hash/hash_tiger.c
Expand Up @@ -197,7 +197,7 @@ PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *i
{
if (context->length + len < 64) {
memcpy(&context->buffer[context->length], input, len);
context->length += (unsigned int) len;
context->length += len;
} else {
size_t i = 0, r = (context->length + len) % 64;

Expand All @@ -216,7 +216,7 @@ PHP_HASH_API void PHP_TIGERUpdate(PHP_TIGER_CTX *context, const unsigned char *i
}
ZEND_SECURE_ZERO(&context->buffer[r], 64-r);
memcpy(context->buffer, &input[i], r);
context->length = (unsigned int) r;
context->length = r;
}
}

Expand Down

0 comments on commit f7991ca

Please sign in to comment.