[ttssh2-commit] [9662] PuTTY 0.76 にアップデート

Back to archive index
scmno****@osdn***** scmno****@osdn*****
2022年 1月 3日 (月) 14:46:41 JST


Revision: 9662
          https://osdn.net/projects/ttssh2/scm/svn/commits/9662
Author:   nmaya
Date:     2022-01-03 14:46:40 +0900 (Mon, 03 Jan 2022)
Log Message:
-----------
PuTTY 0.76 にアップデート

merge from putty_0_76:
r9626,r9635,r9636,r9644

Revision Links:
--------------
    https://osdn.net/projects/ttssh2/scm/svn/commits/9626
    https://osdn.net/projects/ttssh2/scm/svn/commits/9635
    https://osdn.net/projects/ttssh2/scm/svn/commits/9636
    https://osdn.net/projects/ttssh2/scm/svn/commits/9644

Modified Paths:
--------------
    trunk/doc/en/html/about/history.html
    trunk/doc/en/html/reference/develop.txt
    trunk/doc/ja/html/about/history.html
    trunk/doc/ja/html/reference/develop.txt
    trunk/libs/putty.cmake
    trunk/ttssh2/putty/CMakeLists.txt
    trunk/ttssh2/putty/libputty.c
    trunk/ttssh2/putty/libputty.h
    trunk/ttssh2/putty/putty.v16.vcxproj
    trunk/ttssh2/putty/putty.v16.vcxproj.filters
    trunk/ttssh2/ttxssh/ssh.c

Added Paths:
-----------
    trunk/ttssh2/putty/putty-import.c

Property Changed:
----------------
    trunk/
    trunk/TTProxy/
    trunk/TTXKanjiMenu/
    trunk/TTXSamples/
    trunk/cygterm/
    trunk/teraterm/
    trunk/ttpmenu/

-------------- next part --------------
Index: trunk
===================================================================
--- trunk	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
## -5,6 +5,7 ##
 /branches/openssl_1_1_1_v2:7785-7786,7788-7808,7811-7812,7814-7815,7819-7822,7829,7832-7834,7838-7843,7846-7847,7855-7856,7858,7861-7863,7873-7877,7880-7881,7884-7888,7890-7892,7894-7895,7898,7900,7902-7903,7909,7924,7934,7954-7957,7959,7973,7975,7979-7980,8019,8208,8256
 /branches/openssl_1_1_1_v3:8258,8264-8265
 /branches/portfwd_memleak:7732,7736-7737,7764
+/branches/putty_0_76:9626,9635-9636,9644
 /branches/serial_port_improved:8119,8140-8141,8144,8150,8158-8160,8163,8170-8172,8183,8185,8204,8209,8212-8215
 /branches/ssh_chacha20poly1305:9209-9212,9217,9229,9248-9253
 /branches/ssh_ed25519:5495-5544
Index: trunk/TTProxy
===================================================================
--- trunk/TTProxy	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/TTProxy	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk/TTProxy
___________________________________________________________________
Modified: svn:mergeinfo
## -1,6 +1,7 ##
 /branches/4-stable/TTProxy:9256-9257
 /branches/openssl_1_1_1_v2/TTProxy:7785-7786,7788-7808,7861-7863,7898,7900,7902-7903,7909,7924,7934,7954-7957,7959,7973,7975,7979-7980
 /branches/openssl_1_1_1_v3/TTProxy:8258
+/branches/putty_0_76/TTProxy:9626,9635-9636,9644
 /branches/ssh_chacha20poly1305/TTProxy:9209-9212,9217,9229,9248-9253
 /branches/ttproxy_improved/TTProxy:8041,8055-8056
 /branches/ttssh_improved/TTProxy:8040
Index: trunk/TTXKanjiMenu
===================================================================
--- trunk/TTXKanjiMenu	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/TTXKanjiMenu	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk/TTXKanjiMenu
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,4 ##
 /branches/4-stable/TTXKanjiMenu:9256-9257
+/branches/putty_0_76/TTXKanjiMenu:9626,9635-9636,9644
 /branches/ssh_chacha20poly1305/TTXKanjiMenu:9209-9212,9217,9229,9248-9253
 /branches/vs2015_warn/TTXKanjiMenu:6194-6285
\ No newline at end of property
Index: trunk/TTXSamples
===================================================================
--- trunk/TTXSamples	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/TTXSamples	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk/TTXSamples
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,4 ##
 /branches/4-stable/TTXSamples:9256-9257
+/branches/putty_0_76/TTXSamples:9626,9635-9636,9644
 /branches/ssh_chacha20poly1305/TTXSamples:9209-9212,9217,9229,9248-9253
 /branches/vs2015_warn/TTXSamples:6194-6285
\ No newline at end of property
Index: trunk/cygterm
===================================================================
--- trunk/cygterm	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/cygterm	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk/cygterm
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,4 ##
 /branches/4-stable/cygterm:9256-9257
 /branches/openssl_1_1_1_v3/cygterm:8284
+/branches/putty_0_76/cygterm:9626,9635-9636,9644
 /branches/ssh_chacha20poly1305/cygterm:9209-9212,9217,9229,9248-9253
\ No newline at end of property
Modified: trunk/doc/en/html/about/history.html
===================================================================
--- trunk/doc/en/html/about/history.html	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/doc/en/html/about/history.html	2022-01-03 05:46:40 UTC (rev 9662)
@@ -47,6 +47,7 @@
 
   <li>Misc
     <ul>
+      <li>Upgraded TTSSH to <a href="#ttssh_2.93">2.93</a>.</li>
       <li>Added about EAR(Export Administration Regulations) to Frequently asked questions.</li>
     </ul>
   </li>
@@ -3298,6 +3299,25 @@
 
 <h2 id="ttssh">TTSSH</h2>
 
+<h3 id="ttssh_2.93">202x.x.x (Ver 2.93 not released)</h3>
+<ul class="history">
+  <!--li>Changes
+    <ul>
+    </ul>
+  </li-->
+
+  <!--li>Bug fixes
+    <ul>
+    </ul>
+  </li-->
+
+  <li>Misc
+    <ul>
+      <li>Upgraded PuTTY to PuTTY 0.76.</li>
+    </ul>
+  </li>
+</ul>
+
 <h3 id="ttssh_2.92">2021.6.5 (Ver 2.92)</h3>
 <ul class="history">
   <li>Changes

Modified: trunk/doc/en/html/reference/develop.txt
===================================================================
--- trunk/doc/en/html/reference/develop.txt	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/doc/en/html/reference/develop.txt	2022-01-03 05:46:40 UTC (rev 9662)
@@ -79,7 +79,7 @@
 - Oniguruma 6.9.7.1 (https://github.com/kkos/oniguruma)
 - OpenSSL 1.1.1k (http://www.openssl.org/)
 - zlib 1.2.11 (http://www.zlib.net/)
-- PuTTY 0.70 (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
+- PuTTY 0.76 (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
 - SFMT 1.5.1 (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index.html)
 - cJSON 1.7.14 (https://github.com/DaveGamble/cJSON/)
 - The reference C implementation of Argon2 20190702 (https://github.com/P-H-C/phc-winner-argon2)

Modified: trunk/doc/ja/html/about/history.html
===================================================================
--- trunk/doc/ja/html/about/history.html	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/doc/ja/html/about/history.html	2022-01-03 05:46:40 UTC (rev 9662)
@@ -47,6 +47,7 @@
 
   <li>\x82\xBB\x82̑\xBC
     <ul>
+      <li><a href="#ttssh_2.93">TTSSH(2.93)</a>\x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
       <li>Q & A\x8FW\x82ɗA\x8Fo\x8BK\x90\xA7(EAR)\x82ɂ‚\xA2\x82ĒNjL\x82\xB5\x82\xBD\x81B</li>
     </ul>
   </li>
@@ -3304,6 +3305,25 @@
 
 <h2 id="ttssh">TTSSH</h2>
 
+<h3 id="ttssh_2.93">202x.x.x (Ver 2.93 not released)</h3>
+<ul class="history">
+  <!--li>\x95ύX
+    <ul>
+    </ul>
+  </li-->
+
+  <!--li>\x83o\x83O\x8FC\x90\xB3
+    <ul>
+    </ul>
+  </li-->
+
+  <li>\x82\xBB\x82̑\xBC
+    <ul>
+      <li>PuTTY 0.76 \x82֍\xB7\x82\xB5\x91ւ\xA6\x82\xBD\x81B</li>
+    </ul>
+  </li>
+</ul>
+
 <h3 id="ttssh_2.92">2021.6.5 (Ver 2.92)</h3>
 <ul class="history">
   <li>\x95ύX

Modified: trunk/doc/ja/html/reference/develop.txt
===================================================================
--- trunk/doc/ja/html/reference/develop.txt	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/doc/ja/html/reference/develop.txt	2022-01-03 05:46:40 UTC (rev 9662)
@@ -72,7 +72,7 @@
 - Oniguruma 6.9.7.1 (https://github.com/kkos/oniguruma)
 - OpenSSL 1.1.1k (http://www.openssl.org/)
 - zlib 1.2.11 (http://www.zlib.net/)
-- PuTTY 0.70 (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
+- PuTTY 0.76 (http://www.chiark.greenend.org.uk/~sgtatham/putty/)
 - SFMT 1.5.1 (http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/SFMT/index-jp.html)
 - cJSON 1.7.14 (https://github.com/DaveGamble/cJSON/)
 - The reference C implementation of Argon2 20190702 (https://github.com/P-H-C/phc-winner-argon2)

Modified: trunk/libs/putty.cmake
===================================================================
--- trunk/libs/putty.cmake	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/libs/putty.cmake	2022-01-03 05:46:40 UTC (rev 9662)
@@ -1,9 +1,9 @@
 # cmake -P putty.cmake
 
-set(SRC_DIR_BASE "putty-0.70")
-set(SRC_ARC "putty-0.70.tar.gz")
-set(SRC_URL "https://the.earth.li/~sgtatham/putty/0.70/putty-0.70.tar.gz")
-set(SRC_ARC_HASH_SHA256 bb8aa49d6e96c5a8e18a057f3150a1695ed99a24eef699e783651d1f24e7b0be)
+set(SRC_DIR_BASE "putty-0.76")
+set(SRC_ARC "putty-0.76.tar.gz")
+set(SRC_URL "https://the.earth.li/~sgtatham/putty/0.76/putty-0.76.tar.gz")
+set(SRC_ARC_HASH_SHA256 547cd97a8daa87ef71037fab0773bceb54a8abccb2f825a49ef8eba5e045713f)
 
 set(DOWN_DIR "${CMAKE_SOURCE_DIR}/download/putty")
 set(EXTRACT_DIR "${CMAKE_SOURCE_DIR}/build/putty/src")

Index: trunk/teraterm
===================================================================
--- trunk/teraterm	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/teraterm	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk/teraterm
___________________________________________________________________
Modified: svn:mergeinfo
## -4,6 +4,7 ##
 /branches/move_code_script/teraterm:9026-9185
 /branches/openssl_1_1_1_v2/teraterm:7819-7822,7829,7832-7834,7838-7843,7846-7847,7855-7856,7858,7861-7863,7979-7980
 /branches/openssl_1_1_1_v3/teraterm:8258
+/branches/putty_0_76/teraterm:9626,9635-9636,9644
 /branches/serial_port_improved/teraterm:8119,8140-8141,8144,8150,8158-8160,8163,8170,8172,8183,8185,8204,8209,8212-8215
 /branches/ssh_chacha20poly1305/teraterm:9209-9212,9217,9229,9248-9253
 /branches/vs2015_warn/teraterm:6194-6285
\ No newline at end of property
Index: trunk/ttpmenu
===================================================================
--- trunk/ttpmenu	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttpmenu	2022-01-03 05:46:40 UTC (rev 9662)

Property changes on: trunk/ttpmenu
___________________________________________________________________
Modified: svn:mergeinfo
## -1,3 +1,4 ##
 /branches/4-stable/ttpmenu:9256-9257
+/branches/putty_0_76/ttpmenu:9626,9635-9636,9644
 /branches/ssh_chacha20poly1305/ttpmenu:9209-9212,9217,9229,9248-9253
 /branches/vs2015_warn/ttpmenu:6194-6285
\ No newline at end of property
Modified: trunk/ttssh2/putty/CMakeLists.txt
===================================================================
--- trunk/ttssh2/putty/CMakeLists.txt	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttssh2/putty/CMakeLists.txt	2022-01-03 05:46:40 UTC (rev 9662)
@@ -7,20 +7,24 @@
 endif()
 
 set(PUTTY_SRC
-  ../../libs/putty/putty.h
-  ../../libs/putty/pageant.h
-  ../../libs/putty/conf.c
-  ../../libs/putty/misc.h
-  ../../libs/putty/misc.c
-  ../../libs/putty/tree234.h
+  ../../libs/putty/aqsync.c
+  ../../libs/putty/callback.c
+  ../../libs/putty/errsock.c
+  ../../libs/putty/marshal.c
+  ../../libs/putty/memory.c
+  ../../libs/putty/mpint.c
+  ../../libs/putty/sshsh256.c
   ../../libs/putty/tree234.c
-  ../../libs/putty/version.h
+  ../../libs/putty/utils.c
   ../../libs/putty/version.c
+  ../../libs/putty/windows/wincapi.c
+  ../../libs/putty/windows/winhandl.c
+  ../../libs/putty/windows/winhsock.c
   ../../libs/putty/windows/winmisc.c
+  ../../libs/putty/windows/winnpc.c
   ../../libs/putty/windows/winpgntc.c
-  ../../libs/putty/windows/winsecur.h
   ../../libs/putty/windows/winsecur.c
-  )
+	  )
 
 source_group(
   "putty"
@@ -31,6 +35,7 @@
 set(SRC
   libputty.c
   libputty.h
+  putty-import.c
   )
 
 include_directories(

Modified: trunk/ttssh2/putty/libputty.c
===================================================================
--- trunk/ttssh2/putty/libputty.c	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttssh2/putty/libputty.c	2022-01-03 05:46:40 UTC (rev 9662)
@@ -1,4 +1,3 @@
-// PuTTY is copyright 1997-2007 Simon Tatham.
 /*
  * Copyright (C) 1994-1998 T. Teranishi
  * (C) 2004- TeraTerm Project
@@ -27,31 +26,59 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
+// PuTTY is copyright 1997-2021 Simon Tatham.
 
 /*
  * putty \x83v\x83\x8D\x83W\x83F\x83N\x83g\x82\xCD
- * - PuTTY \x82̃\\x81[\x83X\x83t\x83@\x83C\x83\x8B (\x83v\x83\x8D\x83W\x83F\x83N\x83g\x82ɓǂݍ\x9E\x82ރt\x83@\x83C\x83\x8B\x82͍ŏ\xAC\x8C\xC0)
- * - libputty.c/h 
+ * - libputty.c/h
  *   PuTTY \x82̋@\x94\\x82𗘗p\x82\xB7\x82\xE9\x83C\x83\x93\x83^\x81[\x83t\x83F\x81[\x83X
- *   PuTTY \x82̃\\x81[\x83X\x83t\x83@\x83C\x83\x8B\x82\xA9\x82\xE7\x95K\x97v\x82Ȋ֐\x94\x82݂̂\xF0\x83R\x83s\x81[
+ *     PuTTY \x82̓\xE0\x95\x94\x8C^\x82Ƃ̕ϊ\xB7
+ * - PuTTY \x82̃\\x81[\x83X\x83R\x81[\x83h (\x83v\x83\x8D\x83W\x83F\x83N\x83g\x82ɓǂݍ\x9E\x82ރt\x83@\x83C\x83\x8B\x82͍ŏ\xAC\x8C\xC0)
+ * -- \x93W\x8AJ\x82\xB5\x82\xBD PuTTY \x82̃\\x81[\x83X\x83t\x83@\x83C\x83\x8B\x82\xF0\x82\xBB\x82̂܂ܓǂݍ\x9E\x82񂾂\xE0\x82\xCC (Putty Files \x83O\x83\x8B\x81[\x83v\x93\xE0)
+ * -- putty \x83v\x83\x8D\x83W\x83F\x83N\x83g\x91\xA4\x82ɃR\x83s\x81[\x82\xB5\x82\xBD\x83\\x81[\x83X\x83R\x81[\x83h (putty-import.c)
+ *    static \x82Ȃ\xBD\x82߂ɌĂяo\x82\xB9\x82Ȃ\xA2\x8A֐\x94\x82\xCC static \x82\xF0\x8AO\x82\xB7
+ *    putty \x82Ŏg\x82\xA4\x95\x94\x95\xAA\x82\xBE\x82\xAF\x82𔲐\x88 (putty \x82Ŏg\x82\xED\x82Ȃ\xA2\x95\x94\x95\xAA\x82ő\x9D\x82\xA6\x82Ă\xB5\x82܂\xA4\x88ˑ\xB6\x82\xF0\x97}\x90\xA7)
  * \x82\xA9\x82\xE7\x90ÓI\x83\x89\x83C\x83u\x83\x89\x83\x8A libputty.lib \x82𐶐\xAC\x82\xB5\x81ATTXSSH \x82\xA9\x82烊\x83\x93\x83N\x82\xB3\x82\xEA\x82ė\x98\x97p\x82\xB3\x82\xEA\x82\xE9\x81B
  * \x82\xBB\x82̂\xBD\x82߁ATTXSSH \x91\xA4\x82̒\xE8\x8B`\x82͎\x9D\x82\xBF\x8D\x9E\x82܂Ȃ\xA2\x81B
  */
 
+#include <stdio.h>
 #include <windows.h>
 #include <assert.h>
 
-#include "sshbn.h"
-
-// from SSHBN.C (ver 0.60)
-#define BIGNUM_INTERNAL
-typedef BignumInt *Bignum;
-
 #include "ssh.h"
+#include "mpint.h"
 
 #include "libputty.h"
 
 
+// pageant.c
+typedef struct KeyListEntry {
+    ptrlen blob, comment;
+    uint32_t flags;
+} KeyListEntry;
+typedef struct KeyList {
+    strbuf *raw_data;
+    KeyListEntry *keys;
+    size_t nkeys;
+    bool broken;
+} KeyList;
+
+// putty.h
+//   aqsync.c
+extern void agent_query_synchronous(strbuf *in, void **out, int *outlen);
+
+// pageant.c
+extern void keylist_free(KeyList *kl);
+
+// pageant.c
+extern KeyList *pageant_get_keylist(unsigned ssh_version);
+
+// putty.h
+//   windows/winpgntc.c
+extern bool agent_exists(void);
+
+
 /*
  * for SSH2
  *   \x8C\xAE\x82̈ꗗ\x82𓾂\xE9
@@ -58,20 +85,47 @@
  */
 int putty_get_ssh2_keylist(unsigned char **keylist)
 {
-	int keylistlen;
+	KeyList *kl;
+	int keylistlen = 0;
+	strbuf *sb_keylist = strbuf_new();
+	size_t i;
 
-	*keylist = get_keylist2(&keylistlen);
-	if (*keylist == NULL){
-		// \x8E擾\x82Ɏ\xB8\x94s
-		return 0;
+	kl = pageant_get_keylist(2);
+	if (kl) {
+		if (kl->broken) {
+			keylist_free(kl);
+			strbuf_free(sb_keylist);
+			return 0;
+		}
+
+		put_uint32(sb_keylist, kl->nkeys);
+		keylistlen += 4;
+		for (i = 0; i < kl->nkeys; i++) {
+			put_uint32(sb_keylist, kl->keys[i].blob.len);
+			keylistlen += 4;
+			put_datapl(sb_keylist, kl->keys[i].blob);
+			keylistlen += kl->keys[i].blob.len;
+			put_uint32(sb_keylist, kl->keys[i].comment.len);
+			keylistlen += 4;
+			put_datapl(sb_keylist, kl->keys[i].comment);
+			keylistlen += kl->keys[i].comment.len;
+		}
+		keylist_free(kl);
+
+		*keylist = strbuf_to_str(sb_keylist);
+
+		return keylistlen;
 	}
-	return keylistlen;
+
+	strbuf_free(sb_keylist);
+	return 0;
 }
 
 /*
  * for SSH2
  *   \x8C\xF6\x8AJ\x8C\xAE\x82ƃf\x81[\x83^\x82\xF0\x93n\x82\xB5\x81A
- *   \x94閧\x8C\xAE\x82ɂ\xE6\x82\xC1\x82ď\x90\x96\xBC\x82\xB3\x82ꂽ\x83f\x81[\x83^\x82𓾂\xE9
+ *   \x94閧\x8C\xAE\x82ɂ\xE6\x82鏐\x96\xBC\x82𓾂\xE9
+ *   ssh2userauth.c (PuTTY 0.76) \x82\xA9\x82\xE7\x8Dč\\x90\xAC
  */
 void *putty_sign_ssh2_key(unsigned char *pubkey /* length(4byte) + data */,
                           unsigned char *data,
@@ -80,43 +134,34 @@
 {
 	void *ret;
 
-	unsigned char *request, *response;
+	unsigned char *response;
 	void *vresponse;
-	int resplen;
-	int pubkeylen, reqlen;
-	int flags = 0;
+	int response_len;
+	int pubkeylen;
+	strbuf *agentreq = strbuf_new_for_agent_query();
+	int signflags = 0;
 
-	pubkeylen = GET_32BIT(pubkey);
-	reqlen = 4 + 1 + (4 + pubkeylen) + (4 + datalen) + 4;
-	request = (unsigned char *)malloc(reqlen);
+	put_byte(agentreq, SSH2_AGENTC_SIGN_REQUEST);
+	pubkeylen = GET_32BIT_MSB_FIRST(pubkey);
+	put_data(agentreq, pubkey, 4 + pubkeylen);
+	put_uint32(agentreq, datalen);
+	put_data(agentreq, data, datalen);
+	put_uint32(agentreq, signflags);
+	agent_query_synchronous(agentreq, &vresponse, &response_len);
+	strbuf_free(agentreq);
 
-	// request length
-	PUT_32BIT(request, reqlen);
-	// request type
-	request[4] = SSH2_AGENTC_SIGN_REQUEST;
-	// public key (length + data)
-	memcpy(request + 5, pubkey, 4 + pubkeylen);
-	// sign data length
-	PUT_32BIT(request + 5 + 4 + pubkeylen, datalen);
-	// sign data
-	memcpy(request + 5 + 4 + pubkeylen + 4, data, datalen);
-	// flags word
-	PUT_32BIT(request + 5 + 4 + pubkeylen + 4 + datalen, flags);
-
-	agent_query(request, reqlen, &vresponse, &resplen, NULL, NULL);
-
 	response = vresponse;
-	if (resplen < 5 || response[4] != SSH2_AGENT_SIGN_RESPONSE) {
+	if (response_len < 5 || response[4] != SSH2_AGENT_SIGN_RESPONSE) {
 		sfree(response);
 		return NULL;
 	}
 
-	ret = snewn(resplen-5, unsigned char);
-	memcpy(ret, response+5, resplen-5);
+	ret = snewn(response_len-5, unsigned char);
+	memcpy(ret, response+5, response_len-5);
 	sfree(response);
 
 	if (outlen)
-		*outlen = resplen-5;
+		*outlen = response_len-5;
 
 	return ret;
 }
@@ -127,14 +172,38 @@
  */
 int putty_get_ssh1_keylist(unsigned char **keylist)
 {
-	int keylistlen;
+	KeyList *kl;
+	int keylistlen = 0;
+	strbuf *sb_keylist = strbuf_new();
+	size_t i;
 
-	*keylist = get_keylist1(&keylistlen);
-	if (*keylist == NULL){
-		// \x8E擾\x82Ɏ\xB8\x94s
-		return 0;
+	kl = pageant_get_keylist(1);
+	if (kl) {
+		if (kl->broken) {
+			keylist_free(kl);
+			strbuf_free(sb_keylist);
+			return 0;
+		}
+
+		put_uint32(sb_keylist, kl->nkeys);
+		keylistlen += 4;
+		for (i = 0; i < kl->nkeys; i++) {
+			put_data(sb_keylist, kl->keys[i].blob.ptr, kl->keys[i].blob.len);
+			keylistlen += kl->keys[i].blob.len;
+			put_uint32(sb_keylist, kl->keys[i].comment.len);
+			keylistlen += 4;
+			put_datapl(sb_keylist, kl->keys[i].comment);
+			keylistlen += kl->keys[i].comment.len;
+		}
+		keylist_free(kl);
+
+		*keylist = strbuf_to_str(sb_keylist);
+
+		return keylistlen;
 	}
-	return keylistlen;
+
+	strbuf_free(sb_keylist);
+	return 0;
 }
 
 /*
@@ -141,6 +210,7 @@
  * for SSH1
  *   \x8C\xF6\x8AJ\x8C\xAE\x82ƈÍ\x86\x89\xBB\x83f\x81[\x83^\x82\xF0\x93n\x82\xB5
  *   \x95\x9C\x8D\x86\x83f\x81[\x83^\x82̃n\x83b\x83V\x83\x85\x82𓾂\xE9
+ *   ssh1login.c (PuTTY 0.76) \x82\xA9\x82\xE7\x8Dč\\x90\xAC
  */
 void *putty_hash_ssh1_challenge(unsigned char *pubkey,
                                 int pubkeylen,
@@ -151,47 +221,31 @@
 {
 	void *ret;
 
-	unsigned char *request, *response, *p;
+	unsigned char *response;
 	void *vresponse;
-	int resplen;
-	int reqlen;
+	int response_len;
+	strbuf *agentreq = strbuf_new_for_agent_query();
 
-	reqlen = 4 + 1 + pubkeylen + datalen + 16 + 4;
-	request = (unsigned char *)malloc(reqlen);
-	p = request;
+	put_byte(agentreq, SSH1_AGENTC_RSA_CHALLENGE);
+	put_data(agentreq, pubkey, pubkeylen);
+	put_data(agentreq, data, datalen);
+	put_data(agentreq, session_id, 16);
+	put_uint32(agentreq, 1); // response format
+	agent_query_synchronous(agentreq, &vresponse, &response_len);
+	strbuf_free(agentreq);
 
-	// request length
-	PUT_32BIT(request, reqlen);
-	// request type
-	request[4] = SSH1_AGENTC_RSA_CHALLENGE;
-	p += 5;
-
-	// public key
-	memcpy(p, pubkey, pubkeylen);
-	p += pubkeylen;
-	// challange from server
-	memcpy(p, data, datalen);
-	p += datalen;
-	// session_id
-	memcpy(p, session_id, 16);
-	p += 16;
-	// response format
-	PUT_32BIT(p, 1);
-
-	agent_query(request, reqlen, &vresponse, &resplen, NULL, NULL);
-
 	response = vresponse;
-	if (resplen < 5 || response[4] != SSH1_AGENT_RSA_RESPONSE) {
+	if (response_len < 5+16 || response[4] != SSH1_AGENT_RSA_RESPONSE) {
 		sfree(response);
 		return NULL;
 	}
 
-	ret = snewn(resplen-5, unsigned char);
-	memcpy(ret, response+5, resplen-5);
+	ret = snewn(response_len-5, unsigned char);
+	memcpy(ret, response+5, response_len-5);
 	sfree(response);
 
 	if (outlen)
-		*outlen = resplen-5;
+		*outlen = response_len-5;
 
 	return ret;
 }
@@ -198,7 +252,7 @@
 
 int putty_get_ssh1_keylen(unsigned char *key, int maxlen)
 {
-	return rsa_public_blob_len(key, maxlen);
+	return rsa_ssh1_public_blob_len(make_ptrlen(key, maxlen));
 }
 
 const char *putty_get_version()
@@ -207,173 +261,15 @@
 	return ver;
 }
 
-/*
- * Following functions are copied from putty source.
- */
-
-// from SSHBN.C (ver 0.63)
-static Bignum newbn(int length)
+void putty_agent_query_synchronous(void *in, int inlen, void **out, int *outlen)
 {
-	Bignum b;
+	strbuf *buf = strbuf_new();
 
-	assert(length >= 0 && length < INT_MAX / BIGNUM_INT_BITS);
-
-	b = snewn(length + 1, BignumInt);
-	if (!b)
-		abort();		       /* FIXME */
-	memset(b, 0, (length + 1) * sizeof(*b));
-	b[0] = length;
-	return b;
+	put_data(buf, in, inlen);
+	agent_query_synchronous(buf, out, outlen);
+	strbuf_free(buf);
 }
 
-// from SSHBN.C (ver 0.65)
-Bignum bignum_from_bytes(const unsigned char *data, int nbytes)
-{
-	Bignum result;
-	int w, i;
-
-	assert(nbytes >= 0 && nbytes < INT_MAX / 8);
-
-	w = (nbytes + BIGNUM_INT_BYTES - 1) / BIGNUM_INT_BYTES; /* bytes->words */
-
-	result = newbn(w);
-	for (i = 1; i <= w; i++)
-		result[i] = 0;
-	for (i = nbytes; i--;) {
-		unsigned char byte = *data++;
-		result[1 + i / BIGNUM_INT_BYTES] |=
-			(BignumInt)byte << (8 * i % BIGNUM_INT_BITS);
-	}
-
-	while (result[0] > 1 && result[result[0]] == 0)
-		result[0]--;
-	return result;
-}
-
-// from SSHBN.C (ver 0.60)
-/*
-* Read an SSH-1-format bignum from a data buffer. Return the number
-* of bytes consumed, or -1 if there wasn't enough data.
-*/
-int ssh1_read_bignum(const unsigned char *data, int len, Bignum * result)
-{
-	const unsigned char *p = data;
-	int i;
-	int w, b;
-
-	if (len < 2)
-		return -1;
-
-	w = 0;
-	for (i = 0; i < 2; i++)
-		w = (w << 8) + *p++;
-	b = (w + 7) / 8;		       /* bits -> bytes */
-
-	if (len < b + 2)
-		return -1;
-
-	if (!result)		       /* just return length */
-		return b + 2;
-
-	*result = bignum_from_bytes(p, b);
-
-	return p + b - data;
-}
-
-// from SSHRSA.C (putty 0.60)
-/* Given a public blob, determine its length. */
-int rsa_public_blob_len(void *data, int maxlen)
-{
-	unsigned char *p = (unsigned char *)data;
-	int n;
-
-	if (maxlen < 4)
-		return -1;
-	p += 4;			       /* length word */
-	maxlen -= 4;
-
-	n = ssh1_read_bignum(p, maxlen, NULL);    /* exponent */
-	if (n < 0)
-		return -1;
-	p += n;
-
-	n = ssh1_read_bignum(p, maxlen, NULL);    /* modulus */
-	if (n < 0)
-		return -1;
-	p += n;
-
-	return p - (unsigned char *)data;
-}
-
-// from WINDOWS\WINPGNT.C (putty 0.63)
-/*
- * Acquire a keylist1 from the primary Pageant; this means either
- * calling make_keylist1 (if that's us) or sending a message to the
- * primary Pageant (if it's not).
- */
-static void *get_keylist1(int *length)
-{
-	void *ret;
-
-	unsigned char request[5], *response;
-	void *vresponse;
-	int resplen;
-	request[4] = SSH1_AGENTC_REQUEST_RSA_IDENTITIES;
-	PUT_32BIT(request, 1);
-
-	agent_query(request, 5, &vresponse, &resplen, NULL, NULL);
-
-	response = vresponse;
-	if (resplen < 5 || response[4] != SSH1_AGENT_RSA_IDENTITIES_ANSWER) {
-		sfree(response);
-		return NULL;
-	}
-
-	ret = snewn(resplen-5, unsigned char);
-	memcpy(ret, response+5, resplen-5);
-	sfree(response);
-
-	if (length)
-		*length = resplen-5;
-
-	return ret;
-}
-
-// from WINDOWS\WINPGNT.C (putty 0.63)
-/*
- * Acquire a keylist2 from the primary Pageant; this means either
- * calling make_keylist2 (if that's us) or sending a message to the
- * primary Pageant (if it's not).
- */
-static void *get_keylist2(int *length)
-{
-	void *ret;
-
-	unsigned char request[5], *response;
-	void *vresponse;
-	int resplen;
-
-	request[4] = SSH2_AGENTC_REQUEST_IDENTITIES;
-	PUT_32BIT(request, 1);
-
-	agent_query(request, 5, &vresponse, &resplen, NULL, NULL);
-
-	response = vresponse;
-	if (resplen < 5 || response[4] != SSH2_AGENT_IDENTITIES_ANSWER) {
-		sfree(response);
-		return NULL;
-	}
-
-	ret = snewn(resplen-5, unsigned char);
-	memcpy(ret, response+5, resplen-5);
-	sfree(response);
-
-	if (length)
-		*length = resplen-5;
-
-	return ret;
-}
-
 BOOL putty_agent_exists()
 {
 	if (agent_exists()) {
@@ -382,20 +278,3 @@
 	return FALSE;
 }
 
-// from WINDOWS\WINDOW.C (putty 0.60)
-/*
- * Print a modal (Really Bad) message box and perform a fatal exit.
- */
-void modalfatalbox(char *fmt, ...)
-{
-	va_list ap;
-	char *stuff, morestuff[100];
-
-	va_start(ap, fmt);
-	stuff = dupvprintf(fmt, ap);
-	va_end(ap);
-	sprintf(morestuff, "%.70s Fatal Error", "TTSSH");
-	MessageBox(NULL, stuff, morestuff,
-	           MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
-	sfree(stuff);
-}

Modified: trunk/ttssh2/putty/libputty.h
===================================================================
--- trunk/ttssh2/putty/libputty.h	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttssh2/putty/libputty.h	2022-01-03 05:46:40 UTC (rev 9662)
@@ -25,24 +25,8 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-// PuTTY is copyright 1997-2007 Simon Tatham.
+// PuTTY is copyright 1997-2021 Simon Tatham.
 
-// pageant.h
-// \x96{\x93\x96\x82\xCD pageant.h \x82\xF0 include \x8Fo\x97\x88\x82\xE9\x82悤\x82ɂ\xB7\x82\xE9\x95\x{30AA0A2}\x82\xA2\x82̂\xA9\x82\xE0\x82\xB5\x82\xEA\x82Ȃ\xA2\x82\xAF\x82\xEA\x82\xC7
-// \x8A֐\x94\x82̃v\x83\x8D\x83g\x83^\x83C\x83v\x90錾\x82\xE0\x82\xB1\x82\xB1\x82ɂ\xA0\x82\xE9\x82̂Ŏ\xE6\x82肠\x82\xA6\x82\xB8\x82\xB1\x82\xB1\x82ŁB
-#define AGENT_MAX_MSGLEN 8192
-
-// \x83G\x83\x89\x81[\x89\x9E\x93\x9A\x97p
-#define SSH_AGENT_FAILURE_MSG "\x00\x00\x00\x01\x05"
-
-// MISC.C
-extern void safefree(void *);
-
-// WINDOWS\WINPGNTC.C
-extern int agent_exists(void);
-extern void *agent_query(void *in, int inlen, void **out, int *outlen,
-                       void (*callback)(void *, void *, int), void *callback_ctx);
-
 int putty_get_ssh2_keylist(unsigned char **keylist);
 void *putty_sign_ssh2_key(unsigned char *pubkey,
                           unsigned char *data,
@@ -57,7 +41,16 @@
                                 int *outlen);
 int putty_get_ssh1_keylen(unsigned char *key, int maxlen);
 const char *putty_get_version();
+void putty_agent_query_synchronous(void *in, int inlen, void **out, int *outlen);
 BOOL putty_agent_exists();
 
-static void *get_keylist1(int *length);
-static void *get_keylist2(int *length);
+// \x83G\x83\x89\x81[\x89\x9E\x93\x9A\x97p
+#define SSH_AGENT_FAILURE_MSG "\x00\x00\x00\x01\x05"
+
+// pageant.h
+#define AGENT_MAX_MSGLEN 262144
+
+// puttymen.h
+//   memory.c
+extern void safefree(void *);
+

Copied: trunk/ttssh2/putty/putty-import.c (from rev 9626, branches/putty_0_76/ttssh2/putty/putty-import.c)
===================================================================
--- trunk/ttssh2/putty/putty-import.c	                        (rev 0)
+++ trunk/ttssh2/putty/putty-import.c	2022-01-03 05:46:40 UTC (rev 9662)
@@ -0,0 +1,446 @@
+/*
+ * Copyright (C) 1994-1998 T. Teranishi
+ * (C) 2004- TeraTerm Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+// PuTTY is copyright 1997-2021 Simon Tatham.
+
+/* 
+ * \x83\\x81[\x83X\x91S\x91̂\xF0\x82\xBB\x82̂܂܃v\x83\x8D\x83W\x83F\x83N\x83g\x82ɒlj\xC1\x82\xB7\x82\xE9\x82ƁA
+ * \x8Eg\x82\xED\x82Ȃ\xA2\x95\x94\x95\xAA\x82ňˑ\xB6\x90悪\x91\x9D\x82\xA6\x81A\x82\xB3\x82\xE7\x82ɂ\xBB\x82̈ˑ\xB6\x90悪\x91\x9D\x82\xA6\x82\xBD\x82苣\x8D\x87\x82\xAA\x8BN\x82\xAB\x82\xE9\x82̂ŁA
+ * PuTTY \x82̃\\x81[\x83X\x82\xA9\x82\xE7\x83R\x83s\x81[\x82\xB5\x82Ă\xAB\x82\xBD\x83R\x81[\x83h
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "ssh.h"
+#include "mpint.h"
+#include "putty.h"
+#include "network.h"
+#include "sshcr.h"
+#include "pageant.h"
+
+
+// from pageant.c (PuTTY 0.76)
+#define DECL_EXT_ENUM(id, name) id,
+enum Extension { KNOWN_EXTENSIONS(DECL_EXT_ENUM) EXT_UNKNOWN };
+#define DEF_EXT_NAMES(id, name) PTRLEN_DECL_LITERAL(name),
+static const ptrlen extension_names[] = { KNOWN_EXTENSIONS(DEF_EXT_NAMES) };
+
+// from pageant.c (PuTTY 0.76)
+typedef struct PageantClientOp {
+    strbuf *buf;
+    bool request_made;
+    BinarySink_DELEGATE_IMPLEMENTATION;
+    BinarySource_IMPLEMENTATION;
+} PageantClientOp;
+
+// from pageant.c (PuTTY 0.76)
+typedef struct KeyListEntry {
+    ptrlen blob, comment;
+    uint32_t flags;
+} KeyListEntry;
+
+// from pageant.c (PuTTY 0.76)
+typedef struct KeyList {
+    strbuf *raw_data;
+    KeyListEntry *keys;
+    size_t nkeys;
+    bool broken;
+} KeyList;
+
+// from pageant.c (PuTTY 0.76)
+static PageantClientOp *pageant_client_op_new(void)
+{
+    PageantClientOp *pco = snew(PageantClientOp);
+    pco->buf = strbuf_new_for_agent_query();
+    pco->request_made = false;
+    BinarySink_DELEGATE_INIT(pco, pco->buf);
+    BinarySource_INIT(pco, "", 0);
+    return pco;
+}
+
+// from pageant.c (PuTTY 0.76)
+static void pageant_client_op_free(PageantClientOp *pco)
+{
+    if (pco->buf)
+        strbuf_free(pco->buf);
+    sfree(pco);
+}
+
+// from pageant.c (PuTTY 0.76)
+static unsigned pageant_client_op_query(PageantClientOp *pco)
+{
+    /* Since we use the same strbuf for the request and the response,
+     * check by assertion that we aren't embarrassingly sending a
+     * previous response back to the agent */
+    assert(!pco->request_made);
+    pco->request_made = true;
+
+    void *response_raw;
+    int resplen_raw;
+    agent_query_synchronous(pco->buf, &response_raw, &resplen_raw);
+    strbuf_clear(pco->buf);
+    put_data(pco->buf, response_raw, resplen_raw);
+    sfree(response_raw);
+
+    /* The data coming back from agent_query_synchronous will have
+        * its length field prepended. So we start by parsing it as an
+        * SSH-formatted string, and then reinitialise our
+        * BinarySource with the interior of that string. */
+    BinarySource_INIT_PL(pco, ptrlen_from_strbuf(pco->buf));
+    BinarySource_INIT_PL(pco, get_string(pco));
+
+    /* Strip off and directly return the type byte, which every client
+     * will need, to save a boilerplate get_byte at each call site */
+    unsigned reply_type = get_byte(pco);
+    if (get_err(pco))
+        reply_type = 256;              /* out-of-range code */
+    return reply_type;
+}
+
+// from pageant.c (PuTTY 0.76)
+void keylist_free(KeyList *kl)
+{
+    sfree(kl->keys);
+    strbuf_free(kl->raw_data);
+    sfree(kl);
+}
+
+// from pageant.c (PuTTY 0.76)
+static PageantClientOp *pageant_request_keylist_1(void)
+{
+    PageantClientOp *pco = pageant_client_op_new();
+    put_byte(pco, SSH1_AGENTC_REQUEST_RSA_IDENTITIES);
+    if (pageant_client_op_query(pco) == SSH1_AGENT_RSA_IDENTITIES_ANSWER)
+        return pco;
+    pageant_client_op_free(pco);
+    return NULL;
+}
+
+// from pageant.c (PuTTY 0.76)
+static PageantClientOp *pageant_request_keylist_2(void)
+{
+    PageantClientOp *pco = pageant_client_op_new();
+    put_byte(pco, SSH2_AGENTC_REQUEST_IDENTITIES);
+    if (pageant_client_op_query(pco) == SSH2_AGENT_IDENTITIES_ANSWER)
+        return pco;
+    pageant_client_op_free(pco);
+    return NULL;
+}
+
+// from pageant.c (PuTTY 0.76)
+static PageantClientOp *pageant_request_keylist_extended(void)
+{
+    PageantClientOp *pco = pageant_client_op_new();
+    put_byte(pco, SSH2_AGENTC_EXTENSION);
+    put_stringpl(pco, extension_names[EXT_LIST_EXTENDED]);
+    if (pageant_client_op_query(pco) == SSH_AGENT_SUCCESS)
+        return pco;
+    pageant_client_op_free(pco);
+    return NULL;
+}
+
+// from pageant.c (PuTTY 0.76)
+KeyList *pageant_get_keylist(unsigned ssh_version)
+{
+    PageantClientOp *pco;
+    bool list_is_extended = false;
+
+    if (ssh_version == 1) {
+        pco = pageant_request_keylist_1();
+    } else {
+        if ((pco = pageant_request_keylist_extended()) != NULL)
+            list_is_extended = true;
+        else
+            pco = pageant_request_keylist_2();
+    }
+
+    if (!pco)
+        return NULL;
+
+    KeyList *kl = snew(KeyList);
+    kl->nkeys = get_uint32(pco);
+    kl->keys = snewn(kl->nkeys, struct KeyListEntry);
+    kl->broken = false;
+
+    for (size_t i = 0; i < kl->nkeys && !get_err(pco); i++) {
+        if (ssh_version == 1) {
+            int bloblen = rsa_ssh1_public_blob_len(
+                make_ptrlen(get_ptr(pco), get_avail(pco)));
+            if (bloblen < 0) {
+                kl->broken = true;
+                bloblen = 0;
+            }
+            kl->keys[i].blob = get_data(pco, bloblen);
+        } else {
+            kl->keys[i].blob = get_string(pco);
+        }
+        kl->keys[i].comment = get_string(pco);
+
+        if (list_is_extended) {
+            ptrlen key_ext_info = get_string(pco);
+            BinarySource src[1];
+            BinarySource_BARE_INIT_PL(src, key_ext_info);
+
+            kl->keys[i].flags = get_uint32(src);
+        } else {
+            kl->keys[i].flags = 0;
+        }
+    }
+
+    if (get_err(pco))
+        kl->broken = true;
+    kl->raw_data = pco->buf;
+    pco->buf = NULL;
+    pageant_client_op_free(pco);
+    return kl;
+}
+
+// from sshrsa.c (PuTTY 0.76)
+/* Given an SSH-1 public key blob, determine its length. */
+int rsa_ssh1_public_blob_len(ptrlen data)
+{
+    BinarySource src[1];
+
+    BinarySource_BARE_INIT_PL(src, data);
+
+    /* Expect a length word, then exponent and modulus. (It doesn't
+     * even matter which order.) */
+    get_uint32(src);
+    mp_free(get_mp_ssh1(src));
+    mp_free(get_mp_ssh1(src));
+
+    if (get_err(src))
+        return -1;
+
+    /* Return the number of bytes consumed. */
+    return src->pos;
+}
+
+// from windows/winmiscs.c (PuTTY 0.76)
+/*
+ * Windows implementation of smemclr (see misc.c) using SecureZeroMemory.
+ */
+void smemclr(void *b, size_t n) {
+    if (b && n > 0)
+        SecureZeroMemory(b, n);
+}
+
+// from be_misc.c (PuTTY 0.76)
+void log_proxy_stderr(Plug *plug, ProxyStderrBuf *psb,
+                      const void *vdata, size_t len)
+{
+    const char *data = (const char *)vdata;
+
+    /*
+     * This helper function allows us to collect the data written to a
+     * local proxy command's standard error in whatever size chunks we
+     * happen to get from its pipe, and whenever we have a complete
+     * line, we pass it to plug_log.
+     *
+     * (We also do this when the buffer in psb fills up, to avoid just
+     * allocating more and more memory forever, and also to keep Event
+     * Log lines reasonably bounded in size.)
+     *
+     * Prerequisites: a plug to log to, and a ProxyStderrBuf stored
+     * somewhere to collect any not-yet-output partial line.
+     */
+
+    while (len > 0) {
+        /*
+         * Copy as much data into psb->buf as will fit.
+         */
+        assert(psb->size < lenof(psb->buf));
+        size_t to_consume = lenof(psb->buf) - psb->size;
+        if (to_consume > len)
+            to_consume = len;
+        memcpy(psb->buf + psb->size, data, to_consume);
+        data += to_consume;
+        len -= to_consume;
+        psb->size += to_consume;
+
+        /*
+         * Output any full lines in psb->buf.
+         */
+        size_t pos = 0;
+        while (pos < psb->size) {
+            char *nlpos = memchr(psb->buf + pos, '\n', psb->size - pos);
+            if (!nlpos)
+                break;
+
+            /*
+             * Found a newline in the buffer, so we can output a line.
+             */
+            size_t endpos = nlpos - psb->buf;
+            while (endpos > pos && (psb->buf[endpos-1] == '\n' ||
+                                    psb->buf[endpos-1] == '\r'))
+                endpos--;
+            char *msg = dupprintf(
+                "proxy: %.*s", (int)(endpos - pos), psb->buf + pos);
+            plug_log(plug, PLUGLOG_PROXY_MSG, NULL, 0, msg, 0);
+            sfree(msg);
+
+            pos = nlpos - psb->buf + 1;
+            assert(pos <= psb->size);
+        }
+
+        /*
+         * If the buffer is completely full and we didn't output
+         * anything, then output the whole thing, flagging it as a
+         * truncated line.
+         */
+        if (pos == 0 && psb->size == lenof(psb->buf)) {
+            char *msg = dupprintf(
+                "proxy (partial line): %.*s", (int)psb->size, psb->buf);
+            plug_log(plug, PLUGLOG_PROXY_MSG, NULL, 0, msg, 0);
+            sfree(msg);
+
+            pos = psb->size = 0;
+        }
+
+        /*
+         * Now move any remaining data up to the front of the buffer.
+         */
+        size_t newsize = psb->size - pos;
+        if (newsize)
+            memmove(psb->buf, psb->buf + pos, newsize);
+        psb->size = newsize;
+
+        /*
+         * And loop round again if there's more data to be read from
+         * our input.
+         */
+    }
+}
+
+// from be_misc.c (PuTTY 0.76)
+void psb_init(ProxyStderrBuf *psb)
+{
+    psb->size = 0;
+}
+
+// from windows/winpgnt.c (PuTTY 0.76)
+void noise_ultralight(NoiseSourceId id, unsigned long data)
+{
+    /* Pageant doesn't use random numbers, so we ignore this */
+}
+
+// from windows/window.c (PuTTY 0.76)
+/*
+ * Print a modal (Really Bad) message box and perform a fatal exit.
+ */
+void modalfatalbox(const char *fmt, ...)
+{
+    va_list ap;
+    char *message, *title;
+
+    va_start(ap, fmt);
+    message = dupvprintf(fmt, ap);
+    va_end(ap);
+    title = dupprintf("%s Fatal Error", "TTSSH");
+    MessageBox(NULL, message, title,
+               MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
+    sfree(message);
+    sfree(title);
+}
+
+// from misc.c (PuTTY 0.76)
+void out_of_memory(void)
+{
+    modalfatalbox("Out of memory");
+}
+
+
+/*
+putty_get_ssh1_keylen()@libputty.c
+	rsa_ssh1_public_blob_len()@sshrsa.c ... import
+
+memory.c / mpint.c / utils.c
+	smemclr()@windows/winmiscs.c ... import
+
+safemalloc()@memory.c
+	out_of_memory()@misc.c ... import
+		modalfatalbox()@windows/window.c ... import
+
+wm_copydata_agent_query()@windows\winpgnt.c
+	got_advapi()@windows\winsecur.c ... include winsecur.c
+
+agent_named_pipe_name()@windows\winpgnt.c
+	get_username()@windows\winmisc.c ... include winmisc.c
+
+agent_connect()@windows\winpgnt.c
+	new_named_pipe_client()@winnpc.c ... include winnpc.c
+		connect_to_named_pipe()@winnpc.c
+		new_error_socket_consume_string()@errsock.c ... include errsock.c
+		make_handle_socket()@winsocket.c ... include winsocket.c
+			handle_input_new()@winhandl.c ... include winhandl.c
+			handle_output_new()@winhandl.c
+			psb_init()@be_misc.c ... import
+			handle_stderr()@winhsock.c
+				log_proxy_stderr()@be_misc.c ... import
+
+agent_named_pipe_name()@windows\winpgnt.c
+	capi_obfuscate_string()@windows\wincapi.c ... include wincapi.c
+		ssh_sha25****@sshsh***** ... include sshsh256.c
+
+handle_got_event()@windows\winhandl.c
+	noise_ultralight()@windows/winpgnt.c
+
+sk_handle_set_frozen()@windows\winhsock.c
+	queue_toplevel_callback()@callback.c ... include callback.c
+sk_handle_close()@windows\winhsock.c
+	delete_callbacks_for_context()@callback.c
+
+winmisc.c refers to tree234 ... include tree234.c
+
+
+
+if include be_misc.c ...
+backend_socket_log()@be_misc.c
+	sk_getaddr()@windows\winnet.c
+	sk_addr_needs_port()@windows\winnet.c
+	conf_get_int()@conf.c
+	logevent()@logging.c
+
+if include sshrsa.c ...
+rsa_components()@sshrsa.c
+	key_components_new()@sshpubk.c
+	key_components_add_text()@sshpubk.c
+	key_components_add_mp()@sshpubk.c
+ssh_rsakex_encrypt()@sshrsa.c
+	hash_simple()@sshauxcrypt.c
+ssh_rsakex_decrypt()@sshrsa.c
+	hash_simple()@sshauxcrypt.c
+rsa_ssh1_encrypt()@sshrsa.c
+	random_read()@sshrand.c
+
+if include sshauxcropt.c ...
+mac_simple()@sshauxcropt.c coflicts mac_simple()@keyfiles-putty.c
+*/

Modified: trunk/ttssh2/putty/putty.v16.vcxproj
===================================================================
--- trunk/ttssh2/putty/putty.v16.vcxproj	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttssh2/putty/putty.v16.vcxproj	2022-01-03 05:46:40 UTC (rev 9662)
@@ -71,14 +71,25 @@
     </ClCompile>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\libs\putty\CONF.C" />
-    <ClCompile Include="..\..\libs\putty\MISC.C" />
-    <ClCompile Include="..\..\libs\putty\TREE234.C" />
-    <ClCompile Include="..\..\libs\putty\VERSION.C" />
-    <ClCompile Include="..\..\libs\putty\WINDOWS\WINMISC.C" />
-    <ClCompile Include="..\..\libs\putty\WINDOWS\WINPGNTC.C" />
-    <ClCompile Include="..\..\libs\putty\WINDOWS\WINSECUR.C" />
+    <ClCompile Include="..\..\libs\putty\aqsync.c" />
+    <ClCompile Include="..\..\libs\putty\callback.c" />
+    <ClCompile Include="..\..\libs\putty\errsock.c" />
+    <ClCompile Include="..\..\libs\putty\marshal.c" />
+    <ClCompile Include="..\..\libs\putty\memory.c" />
+    <ClCompile Include="..\..\libs\putty\mpint.c" />
+    <ClCompile Include="..\..\libs\putty\sshsh256.c" />
+    <ClCompile Include="..\..\libs\putty\tree234.c" />
+    <ClCompile Include="..\..\libs\putty\utils.c" />
+    <ClCompile Include="..\..\libs\putty\version.c" />
+    <ClCompile Include="..\..\libs\putty\windows\wincapi.c" />
+    <ClCompile Include="..\..\libs\putty\windows\winhandl.c" />
+    <ClCompile Include="..\..\libs\putty\windows\winhsock.c" />
+    <ClCompile Include="..\..\libs\putty\windows\winmisc.c" />
+    <ClCompile Include="..\..\libs\putty\windows\winnpc.c" />
+    <ClCompile Include="..\..\libs\putty\windows\winpgntc.c" />
+    <ClCompile Include="..\..\libs\putty\windows\winsecur.c" />
     <ClCompile Include="libputty.c" />
+    <ClCompile Include="putty-import.c" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="libputty.h" />

Modified: trunk/ttssh2/putty/putty.v16.vcxproj.filters
===================================================================
--- trunk/ttssh2/putty/putty.v16.vcxproj.filters	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttssh2/putty/putty.v16.vcxproj.filters	2022-01-03 05:46:40 UTC (rev 9662)
@@ -6,28 +6,59 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\libs\putty\CONF.C">
+    <ClCompile Include="..\..\libs\putty\aqsync.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\libs\putty\MISC.C">
+    <ClCompile Include="..\..\libs\putty\callback.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\libs\putty\TREE234.C">
+    <ClCompile Include="..\..\libs\putty\errsock.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\libs\putty\VERSION.C">
+    <ClCompile Include="..\..\libs\putty\marshal.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\libs\putty\WINDOWS\WINMISC.C">
+    <ClCompile Include="..\..\libs\putty\memory.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\libs\putty\WINDOWS\WINPGNTC.C">
+    <ClCompile Include="..\..\libs\putty\mpint.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\..\libs\putty\WINDOWS\WINSECUR.C">
+    <ClCompile Include="..\..\libs\putty\sshsh256.c">
       <Filter>Putty Files</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\libs\putty\tree234.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\utils.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\version.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\wincapi.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\winhandl.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\winhsock.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\winmisc.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\winnpc.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\winpgntc.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\libs\putty\windows\winsecur.c">
+      <Filter>Putty Files</Filter>
+    </ClCompile>
     <ClCompile Include="libputty.c" />
+    <ClCompile Include="putty-import.c" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="libputty.h" />

Modified: trunk/ttssh2/ttxssh/ssh.c
===================================================================
--- trunk/ttssh2/ttxssh/ssh.c	2022-01-01 08:58:28 UTC (rev 9661)
+++ trunk/ttssh2/ttxssh/ssh.c	2022-01-03 05:46:40 UTC (rev 9662)
@@ -9503,9 +9503,9 @@
 		data = agent_msg->buf;
 	}
 
-	agent_query(data, *agent_request_len, &response, &resplen, NULL, NULL);
+	putty_agent_query_synchronous(data, *agent_request_len, &response, &resplen);
 	if (response == NULL || resplen < 5) {
-		logprintf(LOG_LEVEL_NOTICE, "%s Agent Forwarding Error: agent_query is failed.", __FUNCTION__);
+		logprintf(LOG_LEVEL_NOTICE, "%s Agent Forwarding Error: putty_agent_query_synchronous is failed.", __FUNCTION__);
 		goto error;
 	}
 


ttssh2-commit メーリングリストの案内
Back to archive index