fixes several signedness issues

Tue, 09 Apr 2019 18:19:52 +0200

author
Mike Becker <universe@uap-core.de>
date
Tue, 09 Apr 2019 18:19:52 +0200
changeset 558
1a9e6a5c1e79
parent 557
90ad7324bbbc
child 559
ba54fc8abdf1

fixes several signedness issues

dav/sync.c file | annotate | diff | comparison | revisions
dav/sync.h file | annotate | diff | comparison | revisions
libidav/resource.c file | annotate | diff | comparison | revisions
libidav/utils.c file | annotate | diff | comparison | revisions
--- 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);
     }
--- 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
 }
--- 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);
             }
--- 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);

mercurial