CVE-2025-4878 Initialize pointers where possible

This is mostly mechanical change initializing all the pointers I was able to
find with some grep and manual review of sources and examples.

Used the following greps (which yield some false positives though):

    git grep "    \w* *\* *\w*;$"
    git grep " ssh_session \w*;"
    git grep " ssh_channel \w*;"
    git grep " struct ssh_iterator \*\w*;"
    git grep " ssh_bind \w*;"
    git grep " ssh_key \w*;"
    git grep " ssh_string \w*;"
    git grep " ssh_buffer \w*;"
    git grep " HMACCTX \w*;"
    git grep " SHACTX \w*;"
    grep -rinP '^(?!.*=)\s*(?:\w+\s+)*\w+\s*\*\s*\w+\s*;'

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2025-04-23 17:57:11 +02:00
committed by Andreas Schneider
parent 5d27f69494
commit 2eb2af4426
62 changed files with 352 additions and 336 deletions

View File

@@ -549,7 +549,7 @@ static void ssh_message_queue(ssh_session session, ssh_message message)
ssh_message ssh_message_pop_head(ssh_session session)
{
ssh_message msg = NULL;
struct ssh_iterator *i;
struct ssh_iterator *i = NULL;
if (session->ssh_message_list == NULL)
return NULL;
@@ -566,7 +566,7 @@ ssh_message ssh_message_pop_head(ssh_session session)
static int ssh_message_termination(void *s)
{
ssh_session session = s;
struct ssh_iterator *it;
struct ssh_iterator *it = NULL;
if (session->session_state == SSH_SESSION_STATE_ERROR)
return 1;
@@ -771,7 +771,7 @@ static ssh_buffer ssh_msg_userauth_build_digest(ssh_session session,
const char *method)
{
struct ssh_crypto_struct *crypto = NULL;
ssh_buffer buffer;
ssh_buffer buffer = NULL;
ssh_string str = NULL;
int rc;
@@ -1092,9 +1092,9 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_request)
#ifdef WITH_GSSAPI
if (strcmp(method, "gssapi-with-mic") == 0) {
uint32_t n_oid;
ssh_string *oids;
ssh_string oid;
char *hexa;
ssh_string *oids = NULL;
ssh_string oid = NULL;
char *hexa = NULL;
int i;
ssh_buffer_get_u32(packet, &n_oid);
n_oid = ntohl(n_oid);
@@ -1187,7 +1187,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
SSH_PACKET_CALLBACK(ssh_packet_userauth_info_response){
uint32_t nanswers;
uint32_t i;
ssh_string tmp;
ssh_string tmp = NULL;
int rc;
ssh_message msg = NULL;
@@ -1429,7 +1429,7 @@ end:
int ssh_message_channel_request_open_reply_accept_channel(ssh_message msg,
ssh_channel chan)
{
ssh_session session;
ssh_session session = NULL;
int rc;
if (msg == NULL) {
@@ -1481,7 +1481,7 @@ int ssh_message_channel_request_open_reply_accept_channel(ssh_message msg,
*/
ssh_channel ssh_message_channel_request_open_reply_accept(ssh_message msg)
{
ssh_channel chan;
ssh_channel chan = NULL;
int rc;
if (msg == NULL) {