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

@@ -346,8 +346,8 @@ void sftp_client_message_free(sftp_client_message msg)
int
sftp_reply_name(sftp_client_message msg, const char *name, sftp_attributes attr)
{
ssh_buffer out;
ssh_string file;
ssh_buffer out = NULL;
ssh_string file = NULL;
out = ssh_buffer_new();
if (out == NULL) {
@@ -428,7 +428,7 @@ int
sftp_reply_names_add(sftp_client_message msg, const char *file,
const char *longname, sftp_attributes attr)
{
ssh_string name;
ssh_string name = NULL;
name = ssh_string_from_char(file);
if (name == NULL) {
@@ -498,8 +498,8 @@ int sftp_reply_names(sftp_client_message msg)
int
sftp_reply_status(sftp_client_message msg, uint32_t status, const char *message)
{
ssh_buffer out;
ssh_string s;
ssh_buffer out = NULL;
ssh_string s = NULL;
out = ssh_buffer_new();
if (out == NULL) {
@@ -655,7 +655,7 @@ int sftp_reply_version(sftp_client_message client_msg)
*/
ssh_string sftp_handle_alloc(sftp_session sftp, void *info)
{
ssh_string ret;
ssh_string ret = NULL;
uint32_t val;
uint32_t i;
@@ -1555,7 +1555,7 @@ process_readlink(sftp_client_message client_msg)
const char *filename = sftp_client_message_get_filename(client_msg);
char buf[PATH_MAX];
int len = -1;
const char *err_msg;
const char *err_msg = NULL;
int status = SSH_FX_OK;
SSH_LOG(SSH_LOG_PROTOCOL, "Processing readlink %s", filename);