svnno****@sourc*****
svnno****@sourc*****
2017年 6月 19日 (月) 21:50:21 JST
Revision: 6808 http://sourceforge.jp/projects/ttssh2/scm/svn/commits/6808 Author: doda Date: 2017-06-19 21:50:21 +0900 (Mon, 19 Jun 2017) Log Message: ----------- logprintf, logprintf_hexdump で引数で pvar を渡すのを廃止した。 Modified Paths: -------------- trunk/ttssh2/ttxssh/buffer.c trunk/ttssh2/ttxssh/crypt.c trunk/ttssh2/ttxssh/dns.c trunk/ttssh2/ttxssh/keyfiles.c trunk/ttssh2/ttxssh/ssh.c trunk/ttssh2/ttxssh/ttxssh.c trunk/ttssh2/ttxssh/ttxssh.h -------------- next part -------------- Modified: trunk/ttssh2/ttxssh/buffer.c =================================================================== --- trunk/ttssh2/ttxssh/buffer.c 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/buffer.c 2017-06-19 12:50:21 UTC (rev 6808) @@ -187,7 +187,7 @@ if (buffer_get_int_ret(&ret, msg) == -1) { // TODO: \x83G\x83\x89\x81[\x8F\x88\x97\x9D - logprintf(NULL, LOG_LEVEL_ERROR, "buffer_get_int: buffer error"); + logprintf(LOG_LEVEL_ERROR, "buffer_get_int: buffer error"); } return (ret); } Modified: trunk/ttssh2/ttxssh/crypt.c =================================================================== --- trunk/ttssh2/ttxssh/crypt.c 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/crypt.c 2017-06-19 12:50:21 UTC (rev 6808) @@ -558,12 +558,12 @@ return TRUE; if (mac->key == NULL) { - logprintf(pvar, LOG_LEVEL_VERBOSE, "HMAC key is NULL(seq %lu len %d)", sequence_number, len); + logprintf(LOG_LEVEL_VERBOSE, "HMAC key is NULL(seq %lu len %d)", sequence_number, len); goto error; } if ((u_int)mac->mac_len > sizeof(m)) { - logprintf(pvar, LOG_LEVEL_VERBOSE, "HMAC len(%d) is larger than %d bytes(seq %lu len %d)", + logprintf(LOG_LEVEL_VERBOSE, "HMAC len(%d) is larger than %d bytes(seq %lu len %d)", mac->mac_len, sizeof(m), sequence_number, len); goto error; } @@ -576,9 +576,9 @@ HMAC_cleanup(&c); if (memcmp(m, MAC, mac->mac_len)) { - logprintf(pvar, LOG_LEVEL_VERBOSE, "HMAC key is not matched(seq %lu len %d)", sequence_number, len); - logprintf_hexdump(pvar, LOG_LEVEL_VERBOSE, m, mac->mac_len, "m:"); - logprintf_hexdump(pvar, LOG_LEVEL_VERBOSE, MAC, mac->mac_len, "MAC:"); + logprintf(LOG_LEVEL_VERBOSE, "HMAC key is not matched(seq %lu len %d)", sequence_number, len); + logprintf_hexdump(LOG_LEVEL_VERBOSE, m, mac->mac_len, "m:"); + logprintf_hexdump(LOG_LEVEL_VERBOSE, MAC, mac->mac_len, "MAC:"); goto error; } Modified: trunk/ttssh2/ttxssh/dns.c =================================================================== --- trunk/ttssh2/ttxssh/dns.c 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/dns.c 2017-06-19 12:50:21 UTC (rev 6808) @@ -84,7 +84,7 @@ default: // Un-supported algorithm hostkey_alg = SSHFP_KEY_RESERVED; } - logprintf(pvar, LOG_LEVEL_VERBOSE, "verify_hostkey_dns: key type = %d, SSHFP type = %d", key->type, hostkey_alg); + logprintf(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: key type = %d, SSHFP type = %d", key->type, hostkey_alg); status = DnsQuery(hostname, DNS_TYPE_SSHFP, DNS_QUERY_STANDARD, NULL, &rec, NULL); @@ -92,7 +92,7 @@ for (p=rec; p!=NULL; p=p->pNext) { if (p->wType == DNS_TYPE_SSHFP) { t = (PDNS_SSHFP_DATA)&(p->Data.Null); - logprintf(pvar, LOG_LEVEL_VERBOSE, + logprintf(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: SSHFP RR: Algorithm = %d, Digest type = %d", t->Algorithm, t->DigestType); if (t->Algorithm == SSHFP_KEY_RESERVED) { @@ -105,7 +105,7 @@ case SSHFP_HASH_SHA1: if (hostkey_alg != SSHFP_KEY_RSA && hostkey_alg != SSHFP_KEY_DSA) { // SHA1 does not allowed to use with ECDSA and ED25519 key - logprintf(pvar, LOG_LEVEL_VERBOSE, + logprintf(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: not allowed digest type. " "Algorithm = %d, Digest type = %d", t->Algorithm, @@ -148,7 +148,7 @@ } } else { - logprintf(pvar, LOG_LEVEL_VERBOSE, "verify_hostkey_dns: not SSHFP RR (%d)", p->wType); + logprintf(LOG_LEVEL_VERBOSE, "verify_hostkey_dns: not SSHFP RR (%d)", p->wType); } } DnsRecordListFree(rec, DnsFreeRecordList); Modified: trunk/ttssh2/ttxssh/keyfiles.c =================================================================== --- trunk/ttssh2/ttxssh/keyfiles.c 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/keyfiles.c 2017-06-19 12:50:21 UTC (rev 6808) @@ -387,7 +387,7 @@ len = fread(buf, 1, sizeof(buf), fp); buffer_append(blob, buf, len); if (buffer_len(blob) > MAX_KEY_FILE_SIZE) { - logprintf(pvar, LOG_LEVEL_WARNING, "%s: key file too large.", __FUNCTION__); + logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": key file too large."); goto error; } if (len < sizeof(buf)) @@ -400,7 +400,7 @@ cp = buffer_ptr(blob); len = buffer_len(blob); if (len < m1len || memcmp(cp, MARK_BEGIN, m1len)) { - logprintf(pvar, LOG_LEVEL_VERBOSE, "%s: missing begin marker", __FUNCTION__); + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": missing begin marker"); goto error; } cp += m1len; @@ -419,7 +419,7 @@ } } if (!len) { - logprintf(pvar, LOG_LEVEL_VERBOSE, "%s: no end marker", __FUNCTION__); + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": no end marker"); goto error; } @@ -426,15 +426,15 @@ // \x83t\x83@\x83C\x83\x8B\x82̃X\x83L\x83\x83\x83\x93\x82\xAA\x8FI\x82\xED\x82\xC1\x82\xBD\x82̂ŁAbase64 decode\x82\xB7\x82\xE9\x81B len = buffer_len(encoded); if ((cp = buffer_append_space(copy_consumed, len)) == NULL) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: buffer_append_space", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": buffer_append_space"); goto error; } if ((dlen = b64decode(cp, len, buffer_ptr(encoded))) < 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: base64 decode failed", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": base64 decode failed"); goto error; } if ((unsigned int)dlen > len) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: crazy base64 length %d > %u", __FUNCTION__, dlen, len); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": crazy base64 length %d > %u", dlen, len); goto error; } @@ -441,7 +441,7 @@ buffer_consume_end(copy_consumed, len - dlen); if (buffer_remain_len(copy_consumed) < sizeof(AUTH_MAGIC) || memcmp(buffer_tail_ptr(copy_consumed), AUTH_MAGIC, sizeof(AUTH_MAGIC))) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: bad magic", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": bad magic"); goto error; } buffer_consume(copy_consumed, sizeof(AUTH_MAGIC)); @@ -453,7 +453,7 @@ ciphername = buffer_get_string_msg(copy_consumed, NULL); ciphernameval = get_cipher_by_name(ciphername); if (ciphernameval == SSH_CIPHER_NONE && strcmp(ciphername, "none") != 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: unknown cipher name", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, "%s: unknown cipher name", __FUNCTION__); goto error; } // \x83p\x83X\x83t\x83\x8C\x81[\x83Y\x82̃`\x83F\x83b\x83N\x81B\x88Í\x86\x89\xBB\x82\xAA none \x82łȂ\xA2\x8Fꍇ\x82͋\xF3\x82̃p\x83X\x83\x8F\x81[\x83h\x82\xF0\x94F\x82߂Ȃ\xA2\x81B @@ -466,11 +466,11 @@ kdfname = buffer_get_string_msg(copy_consumed, NULL); if (kdfname == NULL || (!strcmp(kdfname, "none") && !strcmp(kdfname, KDFNAME))) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: unknown kdf name", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": unknown kdf name"); goto error; } if (!strcmp(kdfname, "none") && strcmp(ciphername, "none") != 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: cipher %s requires kdf", __FUNCTION__, ciphername); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ "%s: cipher %s requires kdf", ciphername); goto error; } @@ -477,12 +477,12 @@ /* kdf options */ kdfp = buffer_get_string_msg(copy_consumed, &klen); if (kdfp == NULL) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: kdf options not set", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": kdf options not set"); goto error; } if (klen > 0) { if ((cp = buffer_append_space(kdf, klen)) == NULL) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: kdf alloc failed", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": kdf alloc failed"); goto error; } memcpy(cp, kdfp, klen); @@ -490,11 +490,11 @@ /* number of keys */ if (buffer_get_int_ret(&nkeys, copy_consumed) < 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: key counter missing", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": key counter missing"); goto error; } if (nkeys != 1) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: only one key supported", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": only one key supported"); goto error; } @@ -501,7 +501,7 @@ /* pubkey */ cp = buffer_get_string_msg(copy_consumed, &len); if (cp == NULL) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: pubkey not found", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": pubkey not found"); goto error; } free(cp); /* XXX check pubkey against decrypted private key */ @@ -511,11 +511,11 @@ blocksize = get_cipher_block_size(ciphernameval); authlen = 0; // TODO: \x82Ƃ肠\x82\xA6\x82\xB8\x8CŒ艻 if (len < blocksize) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: encrypted data too small", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": encrypted data too small"); goto error; } if (len % blocksize) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: length not multiple of blocksize", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": length not multiple of blocksize"); goto error; } @@ -526,7 +526,7 @@ if (!strcmp(kdfname, KDFNAME)) { salt = buffer_get_string_msg(kdf, &slen); if (salt == NULL) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: salt not set", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": salt not set"); goto error; } rounds = buffer_get_int(kdf); @@ -533,7 +533,7 @@ // TODO: error check if (bcrypt_pbkdf(passphrase, strlen(passphrase), salt, slen, key, keylen + ivlen, rounds) < 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: bcrypt_pbkdf failed", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": bcrypt_pbkdf failed"); goto error; } } @@ -550,8 +550,8 @@ buffer_consume(copy_consumed, len); if (buffer_remain_len(copy_consumed) != 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: key blob has trailing data (len = %u)", - __FUNCTION__, buffer_remain_len(copy_consumed)); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": key blob has trailing data (len = %u)", + buffer_remain_len(copy_consumed)); goto error; } @@ -558,12 +558,12 @@ /* check bytes */ if (buffer_get_int_ret(&check1, b) < 0 || buffer_get_int_ret(&check2, b) < 0) { - logprintf(pvar, LOG_LEVEL_ERROR, "check bytes missing"); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": check bytes missing"); goto error; } if (check1 != check2) { - logprintf(pvar, LOG_LEVEL_VERBOSE, "%s: decrypt failed: 0x%08x != 0x%08x", - __FUNCTION__, check1, check2); + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": decrypt failed: 0x%08x != 0x%08x", + check1, check2); goto error; } @@ -578,7 +578,7 @@ while (buffer_remain_len(b)) { if (buffer_get_char_ret(&pad, b) == -1 || pad != (++i & 0xff)) { - logprintf(pvar, LOG_LEVEL_ERROR, "%s: bad padding", __FUNCTION__); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": bad padding"); key_free(keyfmt); keyfmt = NULL; goto error; Modified: trunk/ttssh2/ttxssh/ssh.c =================================================================== --- trunk/ttssh2/ttxssh/ssh.c 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/ssh.c 2017-06-19 12:50:21 UTC (rev 6808) @@ -2853,7 +2853,7 @@ set_uint32(outmsg + 8, x); // window width (pixels) set_uint32(outmsg + 12, y); // window height (pixels) finish_send_packet(pvar); - logprintf(pvar, LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH_CMSG_WINDOW_SIZE. " + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH_CMSG_WINDOW_SIZE. " "cols: %d, rows: %d, x: %d, y: %d", cols, rows, x, y); } @@ -2888,7 +2888,7 @@ finish_send_packet(pvar); buffer_free(msg); - logprintf(pvar, LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " "local: %d, remote: %d, request-type: %s, cols: %d, rows: %d, x: %d, y: %d", c->self_id, c->remote_id, req_type, cols, rows, x, y); @@ -2929,7 +2929,7 @@ finish_send_packet(pvar); buffer_free(msg); - logprintf(pvar, LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " "local: %d, remote: %d, request-type: %s, break-length: %d", c->self_id, c->remote_id, req_type, 1000); @@ -3720,7 +3720,7 @@ finish_send_packet(pvar); buffer_free(msg); - logprintf(pvar, LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " "local: %d, remote: %d, request-type: %s, proto: %s, cookie: %s, screen: %d", c->self_id, c->remote_id, req_type, auth_protocol, newdata, screen_num); @@ -7317,11 +7317,11 @@ ret = DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_SSHPASSWD_INPUT), pvar->cv->HWin, passwd_change_dialog, (LPARAM)&cp); if (ret == -1) { - logprintf(pvar, LOG_LEVEL_WARNING, __FUNCTION__ ": DialogBoxParam failed."); + logprintf(LOG_LEVEL_WARNING, __FUNCTION__ ": DialogBoxParam failed."); return FALSE; } else if (ret == 0) { - logprintf(pvar, LOG_LEVEL_NOTICE, __FUNCTION__ ": dialog cancelled."); + logprintf(LOG_LEVEL_NOTICE, __FUNCTION__ ": dialog cancelled."); return FALSE; } @@ -7406,7 +7406,7 @@ finish_send_packet(pvar); buffer_free(msg); - logprintf(pvar, LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " "local: %d, remote: %d, request-type: %s, msg1=%s, msg2=%s", c->self_id, c->remote_id, req, msg1 ? msg1 : "none", msg2 ? msg2 : "none"); return TRUE; @@ -7488,7 +7488,7 @@ buffer_free(ttymsg); notify_verbose_message(pvar, "SSH2_MSG_CHANNEL_REQUEST was sent at send_pty_request().", LOG_LEVEL_VERBOSE); - logprintf(pvar, LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " + logprintf(LOG_LEVEL_VERBOSE, __FUNCTION__ ": sending SSH2_MSG_CHANNEL_REQUEST. " "local: %d, remote: %d, request-type: %s, " "term: %s, cols: %d, rows: %d, x: %d, y: %d, " "out-speed: %d, in-speed: %d, verase: %s, onlcr: %s", @@ -7614,7 +7614,7 @@ break; default: // NOT REACHED - logprintf(pvar, LOG_LEVEL_ERROR, __FUNCTION__ ": Invalid channel-type. (%d)", c->type); + logprintf(LOG_LEVEL_ERROR, __FUNCTION__ ": Invalid channel-type. (%d)", c->type); return FALSE; } return TRUE; @@ -9131,7 +9131,7 @@ if (agent_msg->len == 0) { req_len = get_uint32_MSBfirst(data); if (req_len > AGENT_MAX_MSGLEN - 4) { - logprintf(pvar, LOG_LEVEL_NOTICE, + logprintf(LOG_LEVEL_NOTICE, __FUNCTION__ ": Agent Forwarding Error: server request is too large. " "size=%u, allowd max=%u.", req_len, AGENT_MAX_MSGLEN-4); if (pvar->session_settings.ForwardAgentNotify) { @@ -9163,7 +9163,7 @@ agent_query(data, *agent_request_len, &response, &resplen, NULL, NULL); if (response == NULL || resplen < 5) { - logprintf(pvar, LOG_LEVEL_NOTICE, __FUNCTION__ "Agent Forwarding Error: agent_query is failed."); + logprintf(LOG_LEVEL_NOTICE, __FUNCTION__ "Agent Forwarding Error: agent_query is failed."); goto error; } Modified: trunk/ttssh2/ttxssh/ttxssh.c =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.c 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/ttxssh.c 2017-06-19 12:50:21 UTC (rev 6808) @@ -946,21 +946,17 @@ } } -void logprintf(PTInstVar pv, int level, char *fmt, ...) +void logprintf(int level, char *fmt, ...) { char buff[4096]; va_list params; - if (pv == NULL) { - pv = pvar; - } - - if (level <= pv->session_settings.LogLevel) { + if (level <= pvar->session_settings.LogLevel) { va_start(params, fmt); vsnprintf_s(buff, sizeof(buff), _TRUNCATE, fmt, params); va_end(params); - notify_verbose_message(pv, buff, level); + notify_verbose_message(pvar, buff, level); } } @@ -1004,7 +1000,7 @@ //strncat_s(buf, buflen, "\n", _TRUNCATE); } -void logprintf_hexdump(PTInstVar pvar, int level, char *data, int len, char *fmt, ...) +void logprintf_hexdump(int level, char *data, int len, char *fmt, ...) { char buff[4096]; va_list params; Modified: trunk/ttssh2/ttxssh/ttxssh.h =================================================================== --- trunk/ttssh2/ttxssh/ttxssh.h 2017-06-19 03:54:18 UTC (rev 6807) +++ trunk/ttssh2/ttxssh/ttxssh.h 2017-06-19 12:50:21 UTC (rev 6808) @@ -343,10 +343,9 @@ void notify_nonfatal_error(PTInstVar pvar, char *msg); void notify_fatal_error(PTInstVar pvar, char *msg, BOOL send_disconnect); void notify_verbose_message(PTInstVar pvar, char *msg, int level); -void logprintf(PTInstVar pvar, int level, char *fmt, ...); -void logprintf_hexdump(PTInstVar pvar, int level, char *data, int len, char *fmt, ...); +void logprintf(int level, char *fmt, ...); +void logprintf_hexdump(int level, char *data, int len, char *fmt, ...); - void get_teraterm_dir_relative_name(char *buf, int bufsize, char *basename); int copy_teraterm_dir_relative_path(char *dest, int destsize, char *basename); void get_file_version(char *exefile, int *major, int *minor, int *release, int *build);