Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed multiple builds - v3.0 #4731

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions deps/libscram/src/scram.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void scram_reset_error() {
errorBuffer[0] = '\0';
}

static 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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -597,15 +597,15 @@ 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;
}
}

/* 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;
}
/*
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down