aboutsummaryrefslogtreecommitdiff
path: root/tools/plink
diff options
context:
space:
mode:
Diffstat (limited to 'tools/plink')
-rw-r--r--tools/plink/makefile16
-rwxr-xr-x[-rw-r--r--]tools/plink/misc.h24
-rwxr-xr-x[-rw-r--r--]tools/plink/ssh.c1
-rwxr-xr-x[-rw-r--r--]tools/plink/sshbn.c22
-rwxr-xr-x[-rw-r--r--]tools/plink/winplink.c55
5 files changed, 95 insertions, 23 deletions
diff --git a/tools/plink/makefile b/tools/plink/makefile
new file mode 100644
index 000000000..cc6425ea4
--- /dev/null
+++ b/tools/plink/makefile
@@ -0,0 +1,16 @@
+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 conf.c callback.c sshshare.c winsecur.c errsock.c winshare.c \
+ winnps.c winnpc.c noterm.c winhsock.c
+
+TTYAPP=plink
diff --git a/tools/plink/misc.h b/tools/plink/misc.h
index d6a80bf0e..d6fea5948 100644..100755
--- a/tools/plink/misc.h
+++ b/tools/plink/misc.h
@@ -106,18 +106,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) | \
@@ -128,16 +128,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/ssh.c b/tools/plink/ssh.c
index 893321e2b..427e6ee3c 100644..100755
--- a/tools/plink/ssh.c
+++ b/tools/plink/ssh.c
@@ -1127,6 +1127,7 @@ static void c_write_stderr(int trusted, const char *buf, int len)
for (i = 0; i < len; i++)
if (buf[i] != '\r' && (trusted || buf[i] == '\n' || (buf[i] & 0x60)))
fputc(buf[i], stderr);
+ fflush(stderr);
}
static void c_write(Ssh ssh, const char *buf, int len)
diff --git a/tools/plink/sshbn.c b/tools/plink/sshbn.c
index a5e0552ff..e71940e31 100644..100755
--- a/tools/plink/sshbn.c
+++ b/tools/plink/sshbn.c
@@ -181,7 +181,7 @@ static BignumInt internal_add(const BignumInt *a, const BignumInt *b,
for (i = len-1; i >= 0; i--) {
carry += (BignumDblInt)a[i] + b[i];
- c[i] = (BignumInt)carry;
+ c[i] = (BignumInt)(carry&BIGNUM_INT_MASK);
carry >>= BIGNUM_INT_BITS;
}
@@ -201,7 +201,7 @@ static void internal_sub(const BignumInt *a, const BignumInt *b,
for (i = len-1; i >= 0; i--) {
carry += (BignumDblInt)a[i] + (b[i] ^ BIGNUM_INT_MASK);
- c[i] = (BignumInt)carry;
+ c[i] = (BignumInt)(carry&BIGNUM_INT_MASK);
carry >>= BIGNUM_INT_BITS;
}
}
@@ -427,7 +427,7 @@ static void internal_mul(const BignumInt *a, const BignumInt *b,
carry = 0;
for (cp = cps, bp = b + len; cp--, bp-- > b ;) {
t = (MUL_WORD(*ap, *bp) + carry) + *cp;
- *cp = (BignumInt) t;
+ *cp = (BignumInt) (t & 0xffffffff);
carry = (BignumInt)(t >> BIGNUM_INT_BITS);
}
*cp = carry;
@@ -529,7 +529,7 @@ static void internal_mul_low(const BignumInt *a, const BignumInt *b,
carry = 0;
for (cp = cps, bp = b + len; bp--, cp-- > c ;) {
t = (MUL_WORD(*ap, *bp) + carry) + *cp;
- *cp = (BignumInt) t;
+ *cp = (BignumInt) (t&BIGNUM_INT_MASK);
carry = (BignumInt)(t >> BIGNUM_INT_BITS);
}
}
@@ -609,7 +609,7 @@ static void internal_add_shifted(BignumInt *number,
while (addend) {
assert(word <= number[0]);
addend += number[word];
- number[word] = (BignumInt) addend & BIGNUM_INT_MASK;
+ number[word] = (BignumInt) (addend & BIGNUM_INT_MASK);
addend >>= BIGNUM_INT_BITS;
word++;
}
@@ -698,9 +698,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 */
@@ -1418,7 +1418,7 @@ Bignum bigmuladd(Bignum a, Bignum b, Bignum addend)
for (i = 1; i <= rlen; i++) {
carry += (i <= (int)ret[0] ? ret[i] : 0);
carry += (i <= (int)addend[0] ? addend[i] : 0);
- ret[i] = (BignumInt) carry & BIGNUM_INT_MASK;
+ ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK);
carry >>= BIGNUM_INT_BITS;
if (ret[i] != 0 && i > maxspot)
maxspot = i;
@@ -1457,7 +1457,7 @@ Bignum bigadd(Bignum a, Bignum b)
for (i = 1; i <= rlen; i++) {
carry += (i <= (int)a[0] ? a[i] : 0);
carry += (i <= (int)b[0] ? b[i] : 0);
- ret[i] = (BignumInt) carry & BIGNUM_INT_MASK;
+ ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK);
carry >>= BIGNUM_INT_BITS;
if (ret[i] != 0 && i > maxspot)
maxspot = i;
@@ -1487,7 +1487,7 @@ Bignum bigsub(Bignum a, Bignum b)
for (i = 1; i <= rlen; i++) {
carry += (i <= (int)a[0] ? a[i] : 0);
carry += (i <= (int)b[0] ? b[i] ^ BIGNUM_INT_MASK : BIGNUM_INT_MASK);
- ret[i] = (BignumInt) carry & BIGNUM_INT_MASK;
+ ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK);
carry >>= BIGNUM_INT_BITS;
if (ret[i] != 0 && i > maxspot)
maxspot = i;
@@ -1556,7 +1556,7 @@ Bignum bignum_add_long(Bignum number, unsigned long addendx)
carry += addend & BIGNUM_INT_MASK;
carry += (i <= (int)number[0] ? number[i] : 0);
addend >>= BIGNUM_INT_BITS;
- ret[i] = (BignumInt) carry & BIGNUM_INT_MASK;
+ ret[i] = (BignumInt) (carry & BIGNUM_INT_MASK);
carry >>= BIGNUM_INT_BITS;
if (ret[i] != 0)
maxspot = i;
diff --git a/tools/plink/winplink.c b/tools/plink/winplink.c
index 451eff3b8..29ed4e5d2 100644..100755
--- 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>
@@ -774,3 +775,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