mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-08 19:02:06 +03:00
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:
committed by
Andreas Schneider
parent
5504ff4051
commit
697650caa9
@@ -30,8 +30,8 @@ int authenticate_kbdint(ssh_session session, const char *password)
|
||||
|
||||
err = ssh_userauth_kbdint(session, NULL, NULL);
|
||||
while (err == SSH_AUTH_INFO) {
|
||||
const char *instruction;
|
||||
const char *name;
|
||||
const char *instruction = NULL;
|
||||
const char *name = NULL;
|
||||
char buffer[128];
|
||||
int i, n;
|
||||
|
||||
@@ -48,8 +48,8 @@ int authenticate_kbdint(ssh_session session, const char *password)
|
||||
}
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
const char *answer;
|
||||
const char *prompt;
|
||||
const char *answer = NULL;
|
||||
const char *prompt = NULL;
|
||||
char echo;
|
||||
|
||||
prompt = ssh_userauth_kbdint_getprompt(session, i, &echo);
|
||||
@@ -58,7 +58,7 @@ int authenticate_kbdint(ssh_session session, const char *password)
|
||||
}
|
||||
|
||||
if (echo) {
|
||||
char *p;
|
||||
char *p = NULL;
|
||||
|
||||
printf("%s", prompt);
|
||||
|
||||
@@ -143,7 +143,7 @@ int authenticate_console(ssh_session session)
|
||||
int rc;
|
||||
int method;
|
||||
char password[128] = {0};
|
||||
char *banner;
|
||||
char *banner = NULL;
|
||||
|
||||
// Try to authenticate
|
||||
rc = ssh_userauth_none(session, NULL);
|
||||
|
@@ -22,7 +22,7 @@ clients must be made or how a client should react.
|
||||
#include <stdio.h>
|
||||
|
||||
ssh_session connect_ssh(const char *host, const char *user,int verbosity){
|
||||
ssh_session session;
|
||||
ssh_session session = NULL;
|
||||
int auth=0;
|
||||
|
||||
session=ssh_new();
|
||||
|
@@ -5,8 +5,8 @@
|
||||
#include "examples_common.h"
|
||||
|
||||
int main(void) {
|
||||
ssh_session session;
|
||||
ssh_channel channel;
|
||||
ssh_session session = NULL;
|
||||
ssh_channel channel = NULL;
|
||||
char buffer[256];
|
||||
int rbytes, wbytes, total = 0;
|
||||
int rc;
|
||||
|
@@ -38,7 +38,7 @@ int verify_knownhost(ssh_session session)
|
||||
char buf[10];
|
||||
unsigned char *hash = NULL;
|
||||
size_t hlen;
|
||||
ssh_key srv_pubkey;
|
||||
ssh_key srv_pubkey = NULL;
|
||||
int rc;
|
||||
|
||||
rc = ssh_get_server_publickey(session, &srv_pubkey);
|
||||
|
@@ -26,9 +26,9 @@ program.
|
||||
#define BUF_SIZE 16384
|
||||
#endif
|
||||
|
||||
static char **sources;
|
||||
static char **sources = NULL;
|
||||
static int nsources;
|
||||
static char *destination;
|
||||
static char *destination = NULL;
|
||||
static int verbosity = 0;
|
||||
|
||||
struct location {
|
||||
@@ -114,9 +114,10 @@ static void location_free(struct location *loc)
|
||||
}
|
||||
}
|
||||
|
||||
static struct location *parse_location(char *loc) {
|
||||
struct location *location;
|
||||
char *ptr;
|
||||
static struct location *parse_location(char *loc)
|
||||
{
|
||||
struct location *location = NULL;
|
||||
char *ptr = NULL;
|
||||
|
||||
location = malloc(sizeof(struct location));
|
||||
if (location == NULL) {
|
||||
|
@@ -35,8 +35,8 @@ clients must be made or how a client should react.
|
||||
static int authenticated=0;
|
||||
static int tries = 0;
|
||||
static int error = 0;
|
||||
static ssh_channel chan=NULL;
|
||||
static char *username;
|
||||
static ssh_channel chan = NULL;
|
||||
static char *username = NULL;
|
||||
static ssh_gssapi_creds client_creds = NULL;
|
||||
|
||||
static int auth_password(ssh_session session, const char *user,
|
||||
@@ -204,11 +204,12 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
||||
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
||||
#endif /* HAVE_ARGP_H */
|
||||
|
||||
int main(int argc, char **argv){
|
||||
ssh_session session;
|
||||
ssh_bind sshbind;
|
||||
ssh_event mainloop;
|
||||
ssh_session client_session;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ssh_session session = NULL;
|
||||
ssh_bind sshbind = NULL;
|
||||
ssh_event mainloop = NULL;
|
||||
ssh_session client_session = NULL;
|
||||
|
||||
struct ssh_server_callbacks_struct cb = {
|
||||
.userdata = NULL,
|
||||
@@ -219,7 +220,7 @@ int main(int argc, char **argv){
|
||||
|
||||
char buf[BUF_SIZE];
|
||||
char host[128]="";
|
||||
char *ptr;
|
||||
char *ptr = NULL;
|
||||
int i,r, rc;
|
||||
|
||||
sshbind=ssh_bind_new();
|
||||
@@ -336,4 +337,3 @@ int main(int argc, char **argv){
|
||||
ssh_finalize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -244,10 +244,11 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
||||
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
||||
#endif /* HAVE_ARGP_H */
|
||||
|
||||
int main(int argc, char **argv){
|
||||
ssh_session session;
|
||||
ssh_bind sshbind;
|
||||
ssh_event mainloop;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ssh_session session = NULL;
|
||||
ssh_bind sshbind = NULL;
|
||||
ssh_event mainloop = NULL;
|
||||
struct ssh_server_callbacks_struct cb = {
|
||||
.userdata = NULL,
|
||||
.auth_none_function = auth_none,
|
||||
@@ -339,4 +340,3 @@ int main(int argc, char **argv){
|
||||
ssh_finalize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -174,8 +174,8 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state) {
|
||||
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
||||
#endif /* HAVE_ARGP_H */
|
||||
|
||||
static const char *name;
|
||||
static const char *instruction;
|
||||
static const char *name = NULL;
|
||||
static const char *instruction = NULL;
|
||||
static const char *prompts[2];
|
||||
static char echo[] = { 1, 0 };
|
||||
|
||||
@@ -279,11 +279,12 @@ static int authenticate(ssh_session session) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
ssh_session session;
|
||||
ssh_bind sshbind;
|
||||
ssh_message message;
|
||||
ssh_channel chan=0;
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ssh_session session = NULL;
|
||||
ssh_bind sshbind = NULL;
|
||||
ssh_message message = NULL;
|
||||
ssh_channel chan = NULL;
|
||||
char buf[BUF_SIZE];
|
||||
int auth=0;
|
||||
int shell=0;
|
||||
@@ -411,4 +412,3 @@ int main(int argc, char **argv){
|
||||
ssh_finalize();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -108,7 +108,7 @@ static int fetch_files(ssh_session session){
|
||||
int size;
|
||||
char buffer[BUF_SIZE];
|
||||
int mode;
|
||||
char *filename;
|
||||
char *filename = NULL;
|
||||
int r;
|
||||
ssh_scp scp=ssh_scp_new(session, SSH_SCP_READ | SSH_SCP_RECURSIVE, "/tmp/libssh_tests/*");
|
||||
if(ssh_scp_init(scp) != SSH_OK){
|
||||
@@ -167,7 +167,7 @@ static int fetch_files(ssh_session session){
|
||||
}
|
||||
|
||||
int main(int argc, char **argv){
|
||||
ssh_session session;
|
||||
ssh_session session = NULL;
|
||||
if(opts(argc,argv)<0)
|
||||
return EXIT_FAILURE;
|
||||
session=connect_ssh(host,NULL,verbosity);
|
||||
|
@@ -6,7 +6,7 @@
|
||||
#define LIMIT 0x100000000UL
|
||||
|
||||
int main(void) {
|
||||
ssh_session session;
|
||||
ssh_session session = NULL;
|
||||
ssh_channel channel;
|
||||
char buffer[1024*1024];
|
||||
int rc;
|
||||
@@ -47,7 +47,7 @@ int main(void) {
|
||||
if(total > LIMIT)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (rc < 0) {
|
||||
printf("error : %s\n",ssh_get_error(session));
|
||||
ssh_channel_close(channel);
|
||||
|
@@ -53,7 +53,7 @@ static struct termios terminal;
|
||||
|
||||
static char *pcap_file = NULL;
|
||||
|
||||
static char *proxycommand;
|
||||
static char *proxycommand = NULL;
|
||||
|
||||
static int auth_callback(const char *prompt,
|
||||
char *buf,
|
||||
@@ -251,7 +251,7 @@ static void select_loop(ssh_session session,ssh_channel channel)
|
||||
|
||||
static void shell(ssh_session session)
|
||||
{
|
||||
ssh_channel channel;
|
||||
ssh_channel channel = NULL;
|
||||
struct termios terminal_local;
|
||||
int interactive=isatty(0);
|
||||
|
||||
@@ -339,7 +339,7 @@ static void batch_shell(ssh_session session)
|
||||
static int client(ssh_session session)
|
||||
{
|
||||
int auth = 0;
|
||||
char *banner;
|
||||
char *banner = NULL;
|
||||
int state;
|
||||
|
||||
if (user) {
|
||||
@@ -423,7 +423,7 @@ static void cleanup_pcap(void)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
ssh_session session;
|
||||
ssh_session session = NULL;
|
||||
|
||||
ssh_init();
|
||||
session = ssh_new();
|
||||
|
@@ -361,7 +361,7 @@ my_fd_data_function(UNUSED_PARAM(socket_t fd),
|
||||
{
|
||||
struct event_fd_data_struct *event_fd_data = (struct event_fd_data_struct *)userdata;
|
||||
ssh_channel channel = event_fd_data->channel;
|
||||
ssh_session session;
|
||||
ssh_session session = NULL;
|
||||
int len, i, wr;
|
||||
char buf[BUF_SIZE];
|
||||
int blocking;
|
||||
@@ -455,8 +455,8 @@ open_tcp_socket(ssh_message msg)
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
int forwardsock = -1;
|
||||
struct hostent *host;
|
||||
const char *dest_hostname;
|
||||
struct hostent *host = NULL;
|
||||
const char *dest_hostname = NULL;
|
||||
int dest_port;
|
||||
|
||||
forwardsock = socket(AF_INET, SOCK_STREAM, 0);
|
||||
@@ -499,8 +499,8 @@ message_callback(UNUSED_PARAM(ssh_session session),
|
||||
UNUSED_PARAM(void *userdata))
|
||||
{
|
||||
ssh_channel channel;
|
||||
int socket_fd, *pFd;
|
||||
struct ssh_channel_callbacks_struct *cb_chan;
|
||||
int socket_fd, *pFd = NULL;
|
||||
struct ssh_channel_callbacks_struct *cb_chan = NULL;
|
||||
struct event_fd_data_struct *event_fd_data;
|
||||
|
||||
_ssh_log(SSH_LOG_PACKET, "=== message_callback", "Message type: %d",
|
||||
@@ -655,8 +655,8 @@ static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
ssh_session session;
|
||||
ssh_bind sshbind;
|
||||
ssh_session session = NULL;
|
||||
ssh_bind sshbind = NULL;
|
||||
struct ssh_server_callbacks_struct cb = {
|
||||
.userdata = NULL,
|
||||
.auth_password_function = auth_password,
|
||||
|
@@ -39,7 +39,7 @@ clients must be made or how a client should react.
|
||||
#define BUF_SIZE 4096
|
||||
#endif
|
||||
|
||||
char *host;
|
||||
char *host = NULL;
|
||||
const char *desthost="localhost";
|
||||
const char *port="22";
|
||||
|
||||
@@ -193,7 +193,7 @@ static void forwarding(ssh_session session){
|
||||
|
||||
static int client(ssh_session session){
|
||||
int auth=0;
|
||||
char *banner;
|
||||
char *banner = NULL;
|
||||
int state;
|
||||
|
||||
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)
|
||||
@@ -246,7 +246,7 @@ void cleanup_pcap(void)
|
||||
#endif
|
||||
|
||||
int main(int argc, char **argv){
|
||||
ssh_session session;
|
||||
ssh_session session = NULL;
|
||||
|
||||
session = ssh_new();
|
||||
|
||||
|
Reference in New Issue
Block a user