From 5ea2f9acc9ea0e084044fb930fb25a5189414801 Mon Sep 17 00:00:00 2001 From: Miro Stauder Date: Thu, 24 Oct 2024 13:02:28 +0000 Subject: [PATCH 1/3] fix ubuntu24 fedora39 40 41 builds --- deps/libscram/src/scram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/libscram/src/scram.c b/deps/libscram/src/scram.c index 3df386c87..954d5d480 100644 --- a/deps/libscram/src/scram.c +++ b/deps/libscram/src/scram.c @@ -43,7 +43,7 @@ void scram_reset_error() { errorBuffer[0] = '\0'; } -static size_t strlcat(char* dst, const char* src, size_t siz) +size_t strlcat(char* dst, const char* src, size_t siz) { char* d = dst; const char* s = src; From 49630c2c2a93c83a76fd5fe7704faf4bc9692791 Mon Sep 17 00:00:00 2001 From: Miro Stauder Date: Thu, 24 Oct 2024 13:24:50 +0000 Subject: [PATCH 2/3] fix wrong type warnings --- deps/libscram/src/scram.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/deps/libscram/src/scram.c b/deps/libscram/src/scram.c index 954d5d480..d04f2133c 100644 --- a/deps/libscram/src/scram.c +++ b/deps/libscram/src/scram.c @@ -597,7 +597,7 @@ static bool calculate_client_proof(ScramState *scram_state, &errstr) < 0 || scram_ClientKey(scram_state->SaltedPassword, PG_SHA256, SCRAM_KEY_LEN, ClientKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute client key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute client key: %s", (const char*) errstr); goto failed; } } @@ -605,7 +605,7 @@ static bool calculate_client_proof(ScramState *scram_state, /* Hash it one more time, and compare with StoredKey */ if (scram_H(ClientKey, PG_SHA256, SCRAM_KEY_LEN, StoredKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not hash stored key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not hash stored key: %s", (const char*) errstr); goto failed; } /* @@ -656,7 +656,7 @@ bool verify_server_signature(ScramState *scram_state, const PgCredentials *crede memcpy(ServerKey, credentials->scram_ServerKey, SCRAM_KEY_LEN); else { if (scram_ServerKey(scram_state->SaltedPassword, PG_SHA256, SCRAM_KEY_LEN, ServerKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute server key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute server key: %s", (const char*) errstr); goto failed; } } @@ -907,17 +907,17 @@ static bool build_adhoc_scram_secret(const char *plain_password, ScramState *scr scram_state->iterations, salted_password, &errstr) < 0 || scram_ClientKey(salted_password, PG_SHA256, SCRAM_KEY_LEN, scram_state->StoredKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute server key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute server key: %s", (const char*) errstr); goto failed; } if (scram_H(scram_state->StoredKey, PG_SHA256, SCRAM_KEY_LEN, scram_state->StoredKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not hash stored key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not hash stored key: %s", (const char*) errstr); goto failed; } if (scram_ServerKey(salted_password, PG_SHA256, SCRAM_KEY_LEN, scram_state->ServerKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not calculate server key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not calculate server key: %s", (const char*) errstr); goto failed; } @@ -1209,7 +1209,7 @@ bool verify_client_proof(ScramState *state, const char *ClientProof) /* Hash it one more time, and compare with StoredKey */ if (scram_H(state->ClientKey, PG_SHA256, SCRAM_KEY_LEN, client_StoredKey, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not hash stored key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not hash stored key: %s", (const char*) errstr); goto failed; } @@ -1271,7 +1271,7 @@ bool scram_verify_plain_password(const char *username, const char *password, /* Compute Server Key based on the user-supplied plaintext password */ if (scram_SaltedPassword(password, PG_SHA256, SCRAM_KEY_LEN, salt, saltlen, iterations, salted_password, &errstr) < 0 || scram_ServerKey(salted_password, PG_SHA256, SCRAM_KEY_LEN, computed_key, &errstr) < 0) { - snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute server key: %s", *errstr); + snprintf(errorBuffer, MAX_ERROR_LENGTH, "could not compute server key: %s", (const char*) errstr); goto failed; } From 2cf6412d74f05539a39e37a1ebda856fd41e25e5 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Fri, 25 Oct 2024 16:24:50 +0500 Subject: [PATCH 3/3] Renamed strlcat to my_strlcat to avoid naming conflict --- deps/libscram/src/scram.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deps/libscram/src/scram.c b/deps/libscram/src/scram.c index d04f2133c..68125597d 100644 --- a/deps/libscram/src/scram.c +++ b/deps/libscram/src/scram.c @@ -43,7 +43,7 @@ void scram_reset_error() { errorBuffer[0] = '\0'; } -size_t strlcat(char* dst, const char* src, size_t siz) +static size_t my_strlcat(char* dst, const char* src, size_t siz) { char* d = dst; const char* s = src; @@ -434,7 +434,7 @@ char *build_client_final_message(ScramState *scram_state, client_proof)) goto failed; - len = strlcat(buf, ",p=", sizeof(buf)); + len = my_strlcat(buf, ",p=", sizeof(buf)); enclen = pg_b64_enc_len(sizeof(client_proof)); enclen = pg_b64_encode((char *) client_proof, SCRAM_KEY_LEN,