diff --git a/NMSSH/NMSFTP.m b/NMSSH/NMSFTP.m index fb19fae..89d259b 100644 --- a/NMSSH/NMSFTP.m +++ b/NMSSH/NMSFTP.m @@ -166,7 +166,7 @@ - (BOOL)removeFileAtPath:(NSString *)path { - (NSData *)contentsAtPath:(NSString *)path { LIBSSH2_SFTP_HANDLE *handle = libssh2_sftp_open(self.sftpSession, [path UTF8String], LIBSSH2_FXF_READ, 0); - char buffer[0x4000]; + char buffer[kNMSSHBufferSize]; long rc = libssh2_sftp_read(handle, buffer, (ssize_t)sizeof(buffer)); libssh2_sftp_close(handle); diff --git a/NMSSH/NMSSH.h b/NMSSH/NMSSH.h index 9207354..a65a37e 100644 --- a/NMSSH/NMSSH.h +++ b/NMSSH/NMSSH.h @@ -5,6 +5,8 @@ #import #import +#define kNMSSHBufferSize (5*1024*1024) + @class NMSSHSession, NMSSHChannel, NMSFTP; #import "NMSSHSession.h" diff --git a/NMSSH/NMSSHChannel.m b/NMSSH/NMSSHChannel.m index 7c8a614..d1f8647 100644 --- a/NMSSH/NMSSHChannel.m +++ b/NMSSH/NMSSHChannel.m @@ -248,7 +248,7 @@ - (NSString *)execute:(NSString *)command error:(NSError *__autoreleasing *)erro NSMutableString *response = [[NSMutableString alloc] init]; for (;;) { ssize_t rc; - char buffer[0x4000]; + char buffer[kNMSSHBufferSize]; char errorBuffer[0x4000]; do { @@ -379,7 +379,7 @@ - (BOOL)startShell:(NSError *__autoreleasing *)error { for (;;) { ssize_t rc; ssize_t erc; - char buffer[0x4000]; + char buffer[kNMSSHBufferSize]; char errorBuffer[0x4000]; do { @@ -523,7 +523,7 @@ - (BOOL)uploadFile:(NSString *)localPath to:(NSString *)remotePath { [self setType:NMSSHChannelTypeSCP]; // Wait for file transfer to finish - char mem[1024]; + char mem[kNMSSHBufferSize]; size_t nread; char *ptr; while ((nread = fread(mem, 1, sizeof(mem), local)) > 0) { @@ -583,7 +583,7 @@ - (BOOL)downloadFile:(NSString *)remotePath to:(NSString *)localPath { // Save data to local file off_t got = 0; while (got < fileinfo.st_size) { - char mem[1024]; + char mem[kNMSSHBufferSize]; long long amount = sizeof(mem); if ((fileinfo.st_size - got) < amount) {