mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-06 16:36:16 +08:00
Fix SSL clients logic bug
This commit is contained in:
@@ -1530,6 +1530,12 @@ int tls_record_do_recv(uint8_t *record, size_t *recordlen, int sock)
|
|||||||
error_print();
|
error_print();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
if (r == 0) {
|
||||||
|
perror("");
|
||||||
|
error_print();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
len -= r;
|
len -= r;
|
||||||
}
|
}
|
||||||
if (!tls_record_type_name(tls_record_type(record))) {
|
if (!tls_record_type_name(tls_record_type(record))) {
|
||||||
@@ -1772,6 +1778,7 @@ int tls_do_recv(TLS_CONNECT *conn)
|
|||||||
if (ret < 0) error_print();
|
if (ret < 0) error_print();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
tls_record_trace(stderr, record, recordlen, 0, 0);
|
tls_record_trace(stderr, record, recordlen, 0, 0);
|
||||||
if (tls_cbc_decrypt(hmac_ctx, dec_key, seq_num, record,
|
if (tls_cbc_decrypt(hmac_ctx, dec_key, seq_num, record,
|
||||||
tls_record_data(record), tls_record_data_length(record),
|
tls_record_data(record), tls_record_data_length(record),
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ int tlcp_client_main(int argc, char *argv[])
|
|||||||
int sock;
|
int sock;
|
||||||
TLS_CTX ctx;
|
TLS_CTX ctx;
|
||||||
TLS_CONNECT conn;
|
TLS_CONNECT conn;
|
||||||
char buf[10] = {0};
|
char buf[1024] = {0};
|
||||||
size_t len = sizeof(buf);
|
size_t len = sizeof(buf);
|
||||||
char send_buf[1024] = {0};
|
char send_buf[1024] = {0};
|
||||||
size_t send_len;
|
size_t send_len;
|
||||||
@@ -202,10 +202,17 @@ bad:
|
|||||||
}
|
}
|
||||||
fwrite(buf, 1, len, stdout);
|
fwrite(buf, 1, len, stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
// 应该调整tls_recv 逻辑、API或者其他方式
|
||||||
|
if (conn.datalen == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (FD_ISSET(STDIN_FILENO, &fds)) {
|
if (FD_ISSET(STDIN_FILENO, &fds)) {
|
||||||
|
fprintf(stderr, "recv from stdin\n");
|
||||||
|
|
||||||
memset(send_buf, 0, sizeof(send_buf));
|
memset(send_buf, 0, sizeof(send_buf));
|
||||||
|
|
||||||
if (!fgets(send_buf, sizeof(send_buf), stdin)) {
|
if (!fgets(send_buf, sizeof(send_buf), stdin)) {
|
||||||
@@ -221,6 +228,8 @@ bad:
|
|||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "end of this round\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -203,6 +203,11 @@ bad:
|
|||||||
}
|
}
|
||||||
fwrite(buf, 1, len, stdout);
|
fwrite(buf, 1, len, stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
// 应该调整tls_recv 逻辑、API或者其他方式
|
||||||
|
if (conn.datalen == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -202,6 +202,11 @@ bad:
|
|||||||
}
|
}
|
||||||
fwrite(buf, 1, len, stdout);
|
fwrite(buf, 1, len, stdout);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
|
// 应该调整tls_recv 逻辑、API或者其他方式
|
||||||
|
if (conn.datalen == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user