summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-01-08 18:13:05 +0100
committerSébastien Helleu <flashcode@flashtux.org>2023-01-08 18:13:05 +0100
commit0bde2aa0f332f7a290809ea578acf620846eccda (patch)
treec74b3aed3a81e803bf6633b0411044021e7d686a
parentf305eed01f5c183ab8c3bb83ea631128cf480be8 (diff)
downloadweechat-0bde2aa0f332f7a290809ea578acf620846eccda.zip
irc: check return code of snprintf
This removes two compiler warnings.
-rw-r--r--src/plugins/irc/irc-sasl.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/plugins/irc/irc-sasl.c b/src/plugins/irc/irc-sasl.c
index d74aa5766..8a520c7d3 100644
--- a/src/plugins/irc/irc-sasl.c
+++ b/src/plugins/irc/irc-sasl.c
@@ -115,7 +115,7 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
char client_signature[512 / 8], client_proof[512 / 8];
char client_proof_base64[((512 / 8) * 4) + 1], server_key[512 / 8];
char server_signature[512 / 8];
- int i, length, num_attrs, iterations, salt_size, salted_password_size;
+ int i, rc, length, num_attrs, iterations, salt_size, salted_password_size;
int client_key_size, stored_key_size, client_signature_size;
int server_key_size, server_signature_size, verifier_size;
long number;
@@ -344,10 +344,12 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
auth_message = malloc (length);
if (!auth_message)
goto memory_error;
- snprintf (auth_message, length, "%s,%s,%s",
- server->sasl_scram_client_first,
- data,
- auth_no_proof);
+ rc = snprintf (auth_message, length, "%s,%s,%s",
+ server->sasl_scram_client_first,
+ data,
+ auth_no_proof);
+ if ((rc < 0) || (rc >= length))
+ goto memory_error;
if (server->sasl_scram_auth_message)
free (server->sasl_scram_auth_message);
server->sasl_scram_auth_message = strdup (auth_message);
@@ -374,9 +376,11 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
/* final message: auth_no_proof + "," + proof */
length = strlen (auth_no_proof) + 3 + strlen (client_proof_base64);
string = malloc (length + 1);
- snprintf (string, length + 1, "%s,p=%s",
- auth_no_proof,
- client_proof_base64);
+ rc = snprintf (string, length + 1, "%s,p=%s",
+ auth_no_proof,
+ client_proof_base64);
+ if ((rc < 0) || (rc >= length + 1))
+ goto memory_error;
}
}
goto end;