# HG changeset patch # User Mike Becker # Date 1554826792 -7200 # Node ID 1a9e6a5c1e79fcb840c9da4a5dbc2908e6019bde # Parent 90ad7324bbbcce5f4c1fab3ee2831b59cc7e31fd fixes several signedness issues diff -r 90ad7324bbbc -r 1a9e6a5c1e79 dav/sync.c --- a/dav/sync.c Sun Apr 07 17:56:31 2019 +0200 +++ b/dav/sync.c Tue Apr 09 18:19:52 2019 +0200 @@ -1087,7 +1087,7 @@ memset(&s, 0, sizeof(SYS_STAT)); char *blocksize_str = dav_get_string_property_ns(res, DAV_NS, "split"); - int64_t blocksize = 0; + uint64_t blocksize = 0; DavBool issplit = FALSE; if(blocksize_str) { if(!util_strtouint(blocksize_str, &blocksize)) { @@ -3146,7 +3146,7 @@ } // set content-hash - char content_hash[DAV_SHA256_DIGEST_LENGTH]; + unsigned char content_hash[DAV_SHA256_DIGEST_LENGTH]; dav_hash_final(sha, content_hash); sync_set_content_hash(res, content_hash); local->hash = util_hexstr(content_hash, DAV_SHA256_DIGEST_LENGTH); @@ -4585,18 +4585,18 @@ return NULL; } -void sync_set_content_hash(DavResource *res, const char *hashdata) { +void sync_set_content_hash(DavResource *res, const unsigned char *hashdata) { uint32_t flags = res->session->flags; if((flags & DAV_SESSION_ENCRYPT_CONTENT) == DAV_SESSION_ENCRYPT_CONTENT) { if(res->session->key) { - char *enc_hash = aes_encrypt(hashdata, DAV_SHA256_DIGEST_LENGTH, res->session->key); + char *enc_hash = aes_encrypt((const char*)hashdata, DAV_SHA256_DIGEST_LENGTH, res->session->key); if(enc_hash) { dav_set_string_property_ns(res, DAV_NS, "crypto-hash", enc_hash); free(enc_hash); } } } else { - char *hex_hash = util_hexstr((const unsigned char*)hashdata, DAV_SHA256_DIGEST_LENGTH); + char *hex_hash = util_hexstr(hashdata, DAV_SHA256_DIGEST_LENGTH); dav_set_string_property_ns(res, DAV_NS, "content-hash", hex_hash); free(hex_hash); } diff -r 90ad7324bbbc -r 1a9e6a5c1e79 dav/sync.h --- a/dav/sync.h Sun Apr 07 17:56:31 2019 +0200 +++ b/dav/sync.h Tue Apr 09 18:19:52 2019 +0200 @@ -222,7 +222,7 @@ * * hashdata must be raw sha256 data and 32 bytes long */ -void sync_set_content_hash(DavResource *res, const char *hashdata); +void sync_set_content_hash(DavResource *res, const unsigned char *hashdata); #ifdef __cplusplus } diff -r 90ad7324bbbc -r 1a9e6a5c1e79 libidav/resource.c --- a/libidav/resource.c Sun Apr 07 17:56:31 2019 +0200 +++ b/libidav/resource.c Tue Apr 09 18:19:52 2019 +0200 @@ -690,7 +690,7 @@ static int dav_seek_h(void *stream, long offset, int whence) { HashStream *s = stream; if(offset == 0 && whence == SEEK_SET) { - char buf[DAV_SHA256_DIGEST_LENGTH]; + unsigned char buf[DAV_SHA256_DIGEST_LENGTH]; dav_hash_final(s->sha, buf); s->sha = NULL; } else { @@ -789,7 +789,7 @@ if(hstr.sha) { dav_hash_final(hstr.sha, (unsigned char*)data->hash); - char *hash = util_hexstr(data->hash, 32); + char *hash = util_hexstr((unsigned char*)data->hash, 32); dav_set_string_property_ns(res, DAV_NS, "content-hash", hash); free(hash); } diff -r 90ad7324bbbc -r 1a9e6a5c1e79 libidav/utils.c --- a/libidav/utils.c Sun Apr 07 17:56:31 2019 +0200 +++ b/libidav/utils.c Tue Apr 09 18:19:52 2019 +0200 @@ -889,7 +889,7 @@ dav_hash_update(sha, buf, r); } - char hash[DAV_SHA256_DIGEST_LENGTH]; + unsigned char hash[DAV_SHA256_DIGEST_LENGTH]; dav_hash_final(sha, hash); free(buf); fclose(in);