cleanup: Fix potential NULL dereference in cmd_omemo_(un)trust
Replace malloc() with g_malloc() to handle allocation failure and ensure enough memory is allocated for the null terminator.
This commit is contained in:
@@ -8714,8 +8714,8 @@ cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* fingerprint;
|
gchar* fingerprint;
|
||||||
char* barejid;
|
gchar* barejid;
|
||||||
|
|
||||||
/* Contact not provided */
|
/* Contact not provided */
|
||||||
if (!args[2]) {
|
if (!args[2]) {
|
||||||
@@ -8731,7 +8731,7 @@ cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args)
|
|||||||
barejid = chatwin->barejid;
|
barejid = chatwin->barejid;
|
||||||
} else {
|
} else {
|
||||||
fingerprint = args[2];
|
fingerprint = args[2];
|
||||||
char* contact = args[1];
|
gchar* contact = args[1];
|
||||||
barejid = roster_barejid_from_name(contact);
|
barejid = roster_barejid_from_name(contact);
|
||||||
if (barejid == NULL) {
|
if (barejid == NULL) {
|
||||||
barejid = contact;
|
barejid = contact;
|
||||||
@@ -8740,7 +8740,7 @@ cmd_omemo_trust(ProfWin* window, const char* const command, gchar** args)
|
|||||||
|
|
||||||
omemo_trust(barejid, fingerprint);
|
omemo_trust(barejid, fingerprint);
|
||||||
|
|
||||||
auto_char char* unformatted_fingerprint = malloc(strlen(fingerprint));
|
auto_gchar gchar* unformatted_fingerprint = g_malloc(strlen(fingerprint) + 1);
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
for (i = 0, j = 0; fingerprint[i] != '\0'; i++) {
|
for (i = 0, j = 0; fingerprint[i] != '\0'; i++) {
|
||||||
@@ -8781,8 +8781,8 @@ cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* fingerprint;
|
gchar* fingerprint;
|
||||||
char* barejid;
|
gchar* barejid;
|
||||||
|
|
||||||
/* Contact not provided */
|
/* Contact not provided */
|
||||||
if (!args[2]) {
|
if (!args[2]) {
|
||||||
@@ -8807,7 +8807,7 @@ cmd_omemo_untrust(ProfWin* window, const char* const command, gchar** args)
|
|||||||
|
|
||||||
omemo_untrust(barejid, fingerprint);
|
omemo_untrust(barejid, fingerprint);
|
||||||
|
|
||||||
auto_char char* unformatted_fingerprint = malloc(strlen(fingerprint));
|
auto_gchar gchar* unformatted_fingerprint = g_malloc(strlen(fingerprint) + 1);
|
||||||
int i, j;
|
int i, j;
|
||||||
for (i = 0, j = 0; fingerprint[i] != '\0'; i++) {
|
for (i = 0, j = 0; fingerprint[i] != '\0'; i++) {
|
||||||
if (!g_ascii_isxdigit(fingerprint[i])) {
|
if (!g_ascii_isxdigit(fingerprint[i])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user