diff options
Diffstat (limited to 'tools/plink')
-rw-r--r-- | tools/plink/makefile | 15 | ||||
-rw-r--r-- | tools/plink/misc.h | 24 | ||||
-rw-r--r-- | tools/plink/sshbn.c | 6 | ||||
-rw-r--r-- | tools/plink/winplink.c | 55 |
4 files changed, 85 insertions, 15 deletions
diff --git a/tools/plink/makefile b/tools/plink/makefile new file mode 100644 index 000000000..893be9c66 --- /dev/null +++ b/tools/plink/makefile @@ -0,0 +1,15 @@ +ifeq ($(MAKESERVER),1)
+$(error Please do not specify MAKESERVER=1 on the command line or as environment variable)
+endif
+
+DEFINES += SECURITY_WIN32
+
+CSRCS = winplink.c winhandl.c misc.c settings.c winstore.c windefs.c winmisc.c wincons.c \
+ logging.c winnet.c tree234.c winnoise.c sshrand.c cmdline.c sshsha.c timing.c \
+ be_all.c rlogin.c proxy.c winproxy.c cproxy.c sshmd5.c time.c version.c ssh.c \
+ sshdh.c sshzlib.c sshbn.c sshrsa.c sshcrcda.c sshpubk.c sshdes.c wingss.c \
+ sshblowf.c sshsh512.c sshsh256.c sshaes.c pinger.c ssharcf.c x11fwd.c winpgntc.c \
+ winx11.c portfwd.c sshcrc.c wildcard.c ldisc.c sshdss.c raw.c telnet.c sshgssc.c \
+ pgssapi.c winnojmp.c
+
+WINAPP=plink
diff --git a/tools/plink/misc.h b/tools/plink/misc.h index 11233147a..fc5b7d53d 100644 --- a/tools/plink/misc.h +++ b/tools/plink/misc.h @@ -92,18 +92,18 @@ void debug_memdump(void *buf, int len, int L); ((unsigned long)(unsigned char)(cp)[3] << 24))
#define PUT_32BIT_LSB_FIRST(cp, value) ( \
- (cp)[0] = (unsigned char)(value), \
- (cp)[1] = (unsigned char)((value) >> 8), \
- (cp)[2] = (unsigned char)((value) >> 16), \
- (cp)[3] = (unsigned char)((value) >> 24) )
+ (cp)[0] = (unsigned char)((value)&0xff), \
+ (cp)[1] = (unsigned char)(((value) >> 8)&0xff), \
+ (cp)[2] = (unsigned char)(((value) >> 16)&0xff), \
+ (cp)[3] = (unsigned char)(((value) >> 24)&0xff) )
#define GET_16BIT_LSB_FIRST(cp) \
(((unsigned long)(unsigned char)(cp)[0]) | \
((unsigned long)(unsigned char)(cp)[1] << 8))
#define PUT_16BIT_LSB_FIRST(cp, value) ( \
- (cp)[0] = (unsigned char)(value), \
- (cp)[1] = (unsigned char)((value) >> 8) )
+ (cp)[0] = (unsigned char)((value)&0xff), \
+ (cp)[1] = (unsigned char)(((value) >> 8)&0xff) )
#define GET_32BIT_MSB_FIRST(cp) \
(((unsigned long)(unsigned char)(cp)[0] << 24) | \
@@ -114,16 +114,16 @@ void debug_memdump(void *buf, int len, int L); #define GET_32BIT(cp) GET_32BIT_MSB_FIRST(cp)
#define PUT_32BIT_MSB_FIRST(cp, value) ( \
- (cp)[0] = (unsigned char)((value) >> 24), \
- (cp)[1] = (unsigned char)((value) >> 16), \
- (cp)[2] = (unsigned char)((value) >> 8), \
- (cp)[3] = (unsigned char)(value) )
+ (cp)[0] = (unsigned char)(((value) >> 24)&0xff), \
+ (cp)[1] = (unsigned char)(((value) >> 16)&0xff), \
+ (cp)[2] = (unsigned char)(((value) >> 8)&0xff), \
+ (cp)[3] = (unsigned char)((value)&0xff) )
#define PUT_32BIT(cp, value) PUT_32BIT_MSB_FIRST(cp, value)
#define GET_16BIT_MSB_FIRST(cp) \
- (((unsigned long)(unsigned char)(cp)[0] << 8) | \
- ((unsigned long)(unsigned char)(cp)[1]))
+ (((unsigned long)(unsigned char)((cp)[0] << 8)&0xff) | \
+ ((unsigned long)(unsigned char)((cp)[1])&0xff))
#define PUT_16BIT_MSB_FIRST(cp, value) ( \
(cp)[0] = (unsigned char)((value) >> 8), \
diff --git a/tools/plink/sshbn.c b/tools/plink/sshbn.c index e9ff0cde4..0fe27ec7d 100644 --- a/tools/plink/sshbn.c +++ b/tools/plink/sshbn.c @@ -151,7 +151,7 @@ static void internal_mul(BignumInt *a, BignumInt *b, for (j = len - 1; j >= 0; j--) {
t += MUL_WORD(a[i], (BignumDblInt) b[j]);
t += (BignumDblInt) c[i + j + 1];
- c[i + j + 1] = (BignumInt) t;
+ c[i + j + 1] = (BignumInt) (t & 0xffffffff);
t = t >> BIGNUM_INT_BITS;
}
c[i] = (BignumInt) t;
@@ -257,9 +257,9 @@ static void internal_mod(BignumInt *a, int alen, t = MUL_WORD(q, m[k]);
t += c;
c = (unsigned)(t >> BIGNUM_INT_BITS);
- if ((BignumInt) t > a[i + k])
+ if (((BignumInt)(t&0xffffffff)) > a[i + k])
c++;
- a[i + k] -= (BignumInt) t;
+ a[i + k] -= (BignumInt) (t&0xffffffff);
}
/* Add back m in case of borrow */
diff --git a/tools/plink/winplink.c b/tools/plink/winplink.c index 7af9e1b4f..0ae519ec0 100644 --- a/tools/plink/winplink.c +++ b/tools/plink/winplink.c @@ -3,6 +3,7 @@ */
#include <stdio.h>
+#include <fcntl.h>
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
@@ -723,3 +724,57 @@ int main(int argc, char **argv) cleanup_exit(exitcode);
return 0; /* placate compiler warning */
}
+
+#ifdef _MSC_VER
+#pragma warning(disable:4273)
+#endif
+
+#ifndef _DEBUG
+_Check_return_opt_ int __cdecl printf(_In_z_ _Printf_format_string_ const char * pFmt, ...)
+{
+ static int ConsoleCreated=0;
+ va_list arglist;
+ if (!ConsoleCreated)
+ {
+ int hConHandle;
+ long lStdHandle;
+ CONSOLE_SCREEN_BUFFER_INFO coninfo;
+
+ FILE *fp;
+ const unsigned int MAX_CONSOLE_LINES = 500;
+ ConsoleCreated=1;
+ if (!AttachConsole(ATTACH_PARENT_PROCESS))
+ AllocConsole();
+
+ // set the screen buffer to be big enough to let us scroll text
+ GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);
+ coninfo.dwSize.Y = MAX_CONSOLE_LINES;
+ SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);
+
+ // redirect unbuffered STDOUT to the console
+ lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "w" );
+ *stdout = *fp;
+ setvbuf( stdout, NULL, _IONBF, 0 );
+
+ // redirect unbuffered STDIN to the console
+ lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "r" );
+ *stdin = *fp;
+ setvbuf( stdin, NULL, _IONBF, 0 );
+
+ // redirect unbuffered STDERR to the console
+ lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
+ hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
+ fp = _fdopen( hConHandle, "w" );
+ *stderr = *fp;
+ setvbuf( stderr, NULL, _IONBF, 0 );
+
+ }
+
+ va_start(arglist, pFmt );
+ return vfprintf(stderr, pFmt, arglist);
+}
+#endif
\ No newline at end of file |