lib/libdmsg: Fix compile warnings on Linux distros
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Mon, 2 Sep 2019 23:00:07 +0000 (08:00 +0900)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Mon, 2 Sep 2019 23:11:34 +0000 (08:11 +0900)
--
crypto.c: In function 'dmsg_crypto_negotiate':
crypto.c:552: warning: pointer targets in passing argument 2 of 'RSA_private_encrypt' differ in signedness
/usr/include/openssl/rsa.h:305: note: expected 'const unsigned char *' but argument is of type 'char *'
crypto.c:552: warning: pointer targets in passing argument 3 of 'RSA_private_encrypt' differ in signedness
/usr/include/openssl/rsa.h:305: note: expected 'unsigned char *' but argument is of type 'char *'

lib/libdmsg/crypto.c

index 2978861..e009486 100644 (file)
@@ -543,14 +543,18 @@ urandfail:
                         */
                        do {
                                ++*(int *)(ptr + 4);
-                               if (RSA_private_encrypt(blksize, ptr, buf1,
+                               if (RSA_private_encrypt(blksize,
+                                           (unsigned char*)ptr,
+                                           (unsigned char*)buf1,
                                            keys[2], RSA_NO_PADDING) < 0) {
                                        iocom->ioq_rx.error =
                                                DMSG_IOQ_ERROR_KEYXCHGFAIL;
                                }
                        } while (buf1[0] & 0xC0);
 
-                       if (RSA_public_encrypt(blksize, buf1, buf2,
+                       if (RSA_public_encrypt(blksize,
+                                           (unsigned char*)buf1,
+                                           (unsigned char*)buf2,
                                            keys[0], RSA_NO_PADDING) < 0) {
                                iocom->ioq_rx.error =
                                        DMSG_IOQ_ERROR_KEYXCHGFAIL;
@@ -580,11 +584,15 @@ urandfail:
                ptr -= (i & blkmask);
                i += n;
                if (keys[0] && (i & blkmask) == 0) {
-                       if (RSA_private_decrypt(blksize, ptr, buf1,
+                       if (RSA_private_decrypt(blksize,
+                                          (unsigned char*)ptr,
+                                          (unsigned char*)buf1,
                                           keys[2], RSA_NO_PADDING) < 0)
                                iocom->ioq_rx.error =
                                                DMSG_IOQ_ERROR_KEYXCHGFAIL;
-                       if (RSA_public_decrypt(blksize, buf1, ptr,
+                       if (RSA_public_decrypt(blksize,
+                                          (unsigned char*)buf1,
+                                          (unsigned char*)ptr,
                                           keys[0], RSA_NO_PADDING) < 0)
                                iocom->ioq_rx.error =
                                                DMSG_IOQ_ERROR_KEYXCHGFAIL;