1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-07-28 01:41:48 +03:00

Replace the hardcode max path length with PATH_MAX

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Icb1d36b48a759ec11dbaa4c09a39037a80ab0f85
This commit is contained in:
Xiang Xiao
2021-05-09 23:53:28 +08:00
committed by Andreas Schneider
parent ae44d846b8
commit d2182bb7af
5 changed files with 12 additions and 10 deletions

View File

@ -17,6 +17,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <limits.h>
#include <sys/select.h> #include <sys/select.h>
#include <sys/time.h> #include <sys/time.h>
@ -297,7 +298,7 @@ static void shell(ssh_session session)
static void batch_shell(ssh_session session) static void batch_shell(ssh_session session)
{ {
ssh_channel channel; ssh_channel channel;
char buffer[1024]; char buffer[PATH_MAX];
size_t i; size_t i;
int s = 0; int s = 0;

View File

@ -29,6 +29,7 @@
#ifndef _LIBSSH_PRIV_H #ifndef _LIBSSH_PRIV_H
#define _LIBSSH_PRIV_H #define _LIBSSH_PRIV_H
#include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -167,6 +168,10 @@ int gettimeofday(struct timeval *__p, void *__t);
#include "libssh/callbacks.h" #include "libssh/callbacks.h"
/* some constants */ /* some constants */
#ifndef PATH_MAX
# define PATH_MAX 4096
#endif
#ifndef MAX_PACKET_LEN #ifndef MAX_PACKET_LEN
#define MAX_PACKET_LEN 262144 #define MAX_PACKET_LEN 262144
#endif #endif

View File

@ -1103,7 +1103,7 @@ int ssh_userauth_publickey_auto(ssh_session session,
while (state->it != NULL) { while (state->it != NULL) {
const char *privkey_file = state->it->data; 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) { if (state->state == SSH_AUTH_AUTO_STATE_PUBKEY) {
SSH_LOG(SSH_LOG_DEBUG, SSH_LOG(SSH_LOG_DEBUG,

View File

@ -119,7 +119,7 @@ error:
int ssh_scp_init(ssh_scp scp) int ssh_scp_init(ssh_scp scp)
{ {
int rc; int rc;
char execbuffer[1024] = {0}; char execbuffer[PATH_MAX] = {0};
char *quoted_location = NULL; char *quoted_location = NULL;
size_t quoted_location_len = 0; size_t quoted_location_len = 0;
size_t scp_location_len; 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) int ssh_scp_push_directory(ssh_scp scp, const char *dirname, int mode)
{ {
char buffer[1024] = {0}; char buffer[PATH_MAX] = {0};
int rc; int rc;
char *dir = NULL; char *dir = NULL;
char *perms = 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 ssh_scp_push_file64(ssh_scp scp, const char *filename, uint64_t size,
int mode) int mode)
{ {
char buffer[1024] = {0}; char buffer[PATH_MAX] = {0};
int rc; int rc;
char *file = NULL; char *file = NULL;
char *perms = 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) int ssh_scp_pull_request(ssh_scp scp)
{ {
char buffer[MAX_BUF_SIZE] = {0}; char buffer[PATH_MAX] = {0};
char *mode = NULL; char *mode = NULL;
char *p, *tmp; char *p, *tmp;
uint64_t size; uint64_t size;

View File

@ -63,10 +63,6 @@
#define TORTURE_SSHD_CONFIG "sshd/sshd_config" #define TORTURE_SSHD_CONFIG "sshd/sshd_config"
#define TORTURE_PCAP_FILE "socket_trace.pcap" #define TORTURE_PCAP_FILE "socket_trace.pcap"
#ifndef PATH_MAX
# define PATH_MAX 4096
#endif
static const char torture_rsa_certauth_pub[]= static const char torture_rsa_certauth_pub[]=
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnA2n5vHzZbs/GvRkGloJNV1CXHI" "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnA2n5vHzZbs/GvRkGloJNV1CXHI"
"S5Xnrm05HusUJSWyPq3I1iCMHdYA7oezHa9GCFYbIenaYPy+G6USQRjYQz8SvAZo06" "S5Xnrm05HusUJSWyPq3I1iCMHdYA7oezHa9GCFYbIenaYPy+G6USQRjYQz8SvAZo06"