diff --git a/examples/ssh_client.c b/examples/ssh_client.c index ec137436..aaf0cb5b 100644 --- a/examples/ssh_client.c +++ b/examples/ssh_client.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -297,7 +298,7 @@ static void shell(ssh_session session) static void batch_shell(ssh_session session) { ssh_channel channel; - char buffer[1024]; + char buffer[PATH_MAX]; size_t i; int s = 0; diff --git a/include/libssh/priv.h b/include/libssh/priv.h index b18ece4c..3e549b79 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -29,6 +29,7 @@ #ifndef _LIBSSH_PRIV_H #define _LIBSSH_PRIV_H +#include #include #include #include @@ -167,6 +168,10 @@ int gettimeofday(struct timeval *__p, void *__t); #include "libssh/callbacks.h" /* some constants */ +#ifndef PATH_MAX +# define PATH_MAX 4096 +#endif + #ifndef MAX_PACKET_LEN #define MAX_PACKET_LEN 262144 #endif diff --git a/src/auth.c b/src/auth.c index fcf39b7a..001368ee 100644 --- a/src/auth.c +++ b/src/auth.c @@ -1103,7 +1103,7 @@ int ssh_userauth_publickey_auto(ssh_session session, while (state->it != NULL) { const char *privkey_file = state->it->data; - char pubkey_file[1024] = {0}; + char pubkey_file[PATH_MAX] = {0}; if (state->state == SSH_AUTH_AUTO_STATE_PUBKEY) { SSH_LOG(SSH_LOG_DEBUG, diff --git a/src/scp.c b/src/scp.c index 85d670a4..946966ea 100644 --- a/src/scp.c +++ b/src/scp.c @@ -119,7 +119,7 @@ error: int ssh_scp_init(ssh_scp scp) { int rc; - char execbuffer[1024] = {0}; + char execbuffer[PATH_MAX] = {0}; char *quoted_location = NULL; size_t quoted_location_len = 0; size_t scp_location_len; @@ -319,7 +319,7 @@ void ssh_scp_free(ssh_scp scp) */ int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode) { - char buffer[1024] = {0}; + char buffer[PATH_MAX] = {0}; int rc; char *dir = NULL; char *perms = NULL; @@ -456,7 +456,7 @@ int ssh_scp_leave_directory(ssh_scp scp) int ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size, int mode) { - char buffer[1024] = {0}; + char buffer[PATH_MAX] = {0}; int rc; char *file = NULL; char *perms = NULL; @@ -769,7 +769,7 @@ int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len) */ int ssh_scp_pull_request(ssh_scp scp) { - char buffer[MAX_BUF_SIZE] = {0}; + char buffer[PATH_MAX] = {0}; char *mode = NULL; char *p, *tmp; uint64_t size; diff --git a/tests/torture.c b/tests/torture.c index 61209185..3d9eb40d 100644 --- a/tests/torture.c +++ b/tests/torture.c @@ -63,10 +63,6 @@ #define TORTURE_SSHD_CONFIG "sshd/sshd_config" #define TORTURE_PCAP_FILE "socket_trace.pcap" -#ifndef PATH_MAX -# define PATH_MAX 4096 -#endif - static const char torture_rsa_certauth_pub[]= "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnA2n5vHzZbs/GvRkGloJNV1CXHI" "S5Xnrm05HusUJSWyPq3I1iCMHdYA7oezHa9GCFYbIenaYPy+G6USQRjYQz8SvAZo06"