Details
-
Type:
Bug
-
Status: Done
-
Priority:
Higher
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 3.17.0
-
Component/s: None
-
Labels:None
-
Story Points:5
-
Epic Link:
Description
In places where we have arrays/buffers of bytes, we should use the unsigned char* type not just char * (which may be signed on some platforms).
Clang reports this as errors:
connection_info.c:156:17: error: initializing 'const char *' with an expression of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] const char *binary = KeyBinaryHash(connection_key, &real_length); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ connection_info.c:161:12: error: returning 'const char *' from a function with result type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] return binary; ^~~~~~ 2 errors generated. make[2]: *** [Makefile:561: connection_info.lo] Error 1 make[2]: *** Waiting for unfinished jobs.... client_protocol.c:239:44: error: passing 'char [4096]' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] nonce_len = BN_bn2mpi(nonce_challenge, in); ^~ /usr/include/openssl/bn.h:227:47: note: passing argument to parameter 'to' here int BN_bn2mpi(const BIGNUM *a, unsigned char *to); ^ client_protocol.c:275:43: error: passing 'char [4096]' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (RSA_public_encrypt(nonce_len, in, out, server_pubkey, RSA_PKCS1_PADDING) <= 0) ^~ /usr/include/openssl/rsa.h:255:55: note: passing argument to parameter 'from' here int RSA_public_encrypt(int flen, const unsigned char *from, ^ client_protocol.c:275:47: error: passing 'char *' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (RSA_public_encrypt(nonce_len, in, out, server_pubkey, RSA_PKCS1_PADDING) <= 0) ^~~ /usr/include/openssl/rsa.h:256:39: note: passing argument to parameter 'to' here unsigned char *to, RSA *rsa, int padding); ^ client_protocol.c:307:31: error: passing 'char [8192]' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] len = BN_bn2mpi(pubkey_n, sendbuffer); ^~~~~~~~~~ /usr/include/openssl/bn.h:227:47: note: passing argument to parameter 'to' here int BN_bn2mpi(const BIGNUM *a, unsigned char *to); ^ client_protocol.c:312:31: error: passing 'char [8192]' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] len = BN_bn2mpi(pubkey_e, sendbuffer); ^~~~~~~~~~ /usr/include/openssl/bn.h:227:47: note: passing argument to parameter 'to' here int BN_bn2mpi(const BIGNUM *a, unsigned char *to); ^ client_protocol.c:347:30: error: passing 'char [4096]' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if ((HashesMatch(digest, in, CF_DEFAULT_DIGEST)) || ^~ ../libntech/libutils/hash.h:158:25: note: passing argument to parameter 'digest2' here const unsigned char digest2[EVP_MAX_MD_SIZE + 1], ^ client_protocol.c:348:30: error: passing 'char [4096]' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] (HashesMatch(digest, in, HASH_METHOD_MD5))) // Legacy ^~ ../libntech/libutils/hash.h:158:25: note: passing argument to parameter 'digest2' here const unsigned char digest2[EVP_MAX_MD_SIZE + 1], ^ client_protocol.c:400:44: error: passing 'char [4096]' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (RSA_private_decrypt(encrypted_len, in, decrypted_cchall, PRIVKEY, RSA_PKCS1_PADDING) <= 0) ^~ /usr/include/openssl/rsa.h:261:56: note: passing argument to parameter 'from' here int RSA_private_decrypt(int flen, const unsigned char *from, ^ client_protocol.c:400:48: error: passing 'char *' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (RSA_private_decrypt(encrypted_len, in, decrypted_cchall, PRIVKEY, RSA_PKCS1_PADDING) <= 0) ^~~~~~~~~~~~~~~~ /usr/include/openssl/rsa.h:262:40: note: passing argument to parameter 'to' here unsigned char *to, RSA *rsa, int padding); ^ client_protocol.c:421:42: error: passing 'unsigned char [65]' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] SendTransaction(conn->conn_info, digest, CF_DEFAULT_DIGEST_LEN, CF_DONE); ^~~~~~ ./net.h:37:60: note: passing argument to parameter 'buffer' here int SendTransaction(ConnectionInfo *conn_info, const char *buffer, int len, char status); ^ client_protocol.c:425:42: error: passing 'unsigned char [65]' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] SendTransaction(conn->conn_info, digest, CF_MD5_LEN, CF_DONE); ^~~~~~ ./net.h:37:60: note: passing argument to parameter 'buffer' here int SendTransaction(ConnectionInfo *conn_info, const char *buffer, int len, char status); ^ client_protocol.c:446:35: error: passing 'char [4096]' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if ((newkey_n = BN_mpi2bn(in, len, NULL)) == NULL) ^~ /usr/include/openssl/bn.h:226:40: note: passing argument to parameter 's' here BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret); ^ client_protocol.c:466:35: error: passing 'char [4096]' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if ((newkey_e = BN_mpi2bn(in, len, NULL)) == NULL) ^~ /usr/include/openssl/bn.h:226:40: note: passing argument to parameter 's' here BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret); ^ client_protocol.c:510:61: error: passing 'char *' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (RSA_public_encrypt(session_size, conn->session_key, out, server_pubkey, RSA_PKCS1_PADDING) <= 0) ^~~ /usr/include/openssl/rsa.h:256:39: note: passing argument to parameter 'to' here unsigned char *to, RSA *rsa, int padding); ^ client_protocol.c:531:29: error: passing 'const unsigned char *' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] LastSaw(conn->remoteip, KeyBinaryHash(conn->conn_info->remote_key, &length), LAST_SEEN_ROLE_CONNECT); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../libpromises/lastseen.h:46:49: note: passing argument to parameter 'digest' here void LastSaw(const char *ipaddress, const char *digest, LastSeenRole role); ^ 15 errors generated. make[2]: *** [Makefile:561: client_protocol.lo] Error 1 client_code.c:659:44: error: passing 'char [4096]' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (!EVP_DecryptUpdate(crypto_ctx, workbuf, &plainlen, buf, cipherlen)) ^~~~~~~ /usr/include/openssl/evp.h:599:70: note: passing argument to parameter 'out' here /*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, ^ client_code.c:659:64: error: passing 'char *' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (!EVP_DecryptUpdate(crypto_ctx, workbuf, &plainlen, buf, cipherlen)) ^~~ /usr/include/openssl/evp.h:600:66: note: passing argument to parameter 'in' here int *outl, const unsigned char *in, int inl); ^ client_code.c:667:46: error: passing 'char *' to parameter of type 'unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] if (!EVP_DecryptFinal_ex(crypto_ctx, workbuf + plainlen, &finlen)) ^~~~~~~~~~~~~~~~~~ /usr/include/openssl/evp.h:603:72: note: passing argument to parameter 'outm' here /*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, ^ 3 errors generated. make[2]: *** [Makefile:561: client_code.lo] Error 1 tls_generic.c:493:39: error: passing 'const char *' to parameter of type 'const unsigned char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] (const char *) "a", ^~~~~~~~~~~~~~~~~~ /usr/include/openssl/x509.h:832:53: note: passing argument to parameter 'bytes' here const unsigned char *bytes, int len, int loc, ^
Attachments
Issue Links
- relates to
-
CFE-3409 Fix format-truncation warnings
-
- Done
-