Skip to content

Commit

Permalink
Merge pull request #4731 from sysown/v3.0_fix_multiple_builds
Browse files Browse the repository at this point in the history
Fixed multiple builds - v3.0
  • Loading branch information
renecannao authored Oct 30, 2024
2 parents 596d5ba + 2cf6412 commit fffca98
Showing 1 changed file with 10 additions and 10 deletions.
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

0 comments on commit fffca98

Please sign in to comment.