aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Southwell <joseph@southwell.org>2014-02-02 19:28:51 +0100
committerAndreas Schneider <asn@cryptomilk.org>2014-02-02 22:19:46 +0100
commit6bbdaceaca06e3af4df5d4f265630ea651bc9044 (patch)
tree793e11158b92870703729d774ba3b469c22369d3
parenteedecd02694cfba2796c79496e1d6c9ebc7ea97a (diff)
downloadlibssh-6bbdaceaca06e3af4df5d4f265630ea651bc9044.tar.gz
libssh-6bbdaceaca06e3af4df5d4f265630ea651bc9044.tar.xz
libssh-6bbdaceaca06e3af4df5d4f265630ea651bc9044.zip
src: Define MAX_BUF_SIZE globally and use it.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--include/libssh/priv.h13
-rw-r--r--src/misc.c1
-rw-r--r--src/scp.c4
-rw-r--r--src/sftp.c2
-rw-r--r--src/socket.c2
5 files changed, 17 insertions, 5 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 0d9e69fa..0e3bab5b 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -120,11 +120,24 @@ int gettimeofday(struct timeval *__p, void *__t);
#include "libssh/callbacks.h"
/* some constants */
+#ifndef MAX_PACKAT_LEN
#define MAX_PACKET_LEN 262144
+#endif
+#ifndef ERROR_BUFFERLEN
#define ERROR_BUFFERLEN 1024
+#endif
+#ifndef CLIENTBANNER1
#define CLIENTBANNER1 "SSH-1.5-libssh-" SSH_STRINGIFY(LIBSSH_VERSION)
+#endif
+#ifndef CLIENTBANNER2
#define CLIENTBANNER2 "SSH-2.0-libssh-" SSH_STRINGIFY(LIBSSH_VERSION)
+#endif
+#ifndef KBDINT_MAX_PROMPT
#define KBDINT_MAX_PROMPT 256 /* more than openssh's :) */
+#endif
+#ifndef MAX_BUF_SIZE
+#define MAX_BUF_SIZE 4096
+#endif
#ifndef __FUNCTION__
#if defined(__SUNPRO_C)
diff --git a/src/misc.c b/src/misc.c
index 693189f2..6daf60ab 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -697,7 +697,6 @@ char *ssh_path_expand_tilde(const char *d) {
}
char *ssh_path_expand_escape(ssh_session session, const char *s) {
-#define MAX_BUF_SIZE 4096
char host[NI_MAXHOST];
char buf[MAX_BUF_SIZE];
char *r, *x = NULL;
diff --git a/src/scp.c b/src/scp.c
index db07aed4..a245402a 100644
--- a/src/scp.c
+++ b/src/scp.c
@@ -545,7 +545,7 @@ int ssh_scp_read_string(ssh_scp scp, char *buffer, size_t len){
* @see ssh_scp_request_get_warning()
*/
int ssh_scp_pull_request(ssh_scp scp){
- char buffer[4096] = {0};
+ char buffer[MAX_BUF_SIZE] = {0};
char *mode=NULL;
char *p,*tmp;
uint64_t size;
@@ -642,7 +642,7 @@ int ssh_scp_pull_request(ssh_scp scp){
* the message failed, or sending it in a bad state.
*/
int ssh_scp_deny_request(ssh_scp scp, const char *reason){
- char buffer[4096];
+ char buffer[MAX_BUF_SIZE];
int err;
if(scp==NULL)
return SSH_ERROR;
diff --git a/src/sftp.c b/src/sftp.c
index b5046f23..36974563 100644
--- a/src/sftp.c
+++ b/src/sftp.c
@@ -308,7 +308,7 @@ int sftp_packet_write(sftp_session sftp, uint8_t type, ssh_buffer payload){
}
sftp_packet sftp_packet_read(sftp_session sftp) {
- unsigned char buffer[4096];
+ unsigned char buffer[MAX_BUF_SIZE];
sftp_packet packet = NULL;
uint32_t size;
int r;
diff --git a/src/socket.c b/src/socket.c
index dd414ef0..935137c1 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -218,7 +218,7 @@ void ssh_socket_set_callbacks(ssh_socket s, ssh_socket_callbacks callbacks){
*/
int ssh_socket_pollcallback(struct ssh_poll_handle_struct *p, socket_t fd, int revents, void *v_s){
ssh_socket s=(ssh_socket )v_s;
- char buffer[4096];
+ char buffer[MAX_BUF_SIZE];
int r;
int err=0;
socklen_t errlen=sizeof(err);