Update version to beta

Fix the record_do_recv bug and update version
This commit is contained in:
Zhi Guan
2022-07-27 17:50:01 +08:00
parent bb1dea9160
commit cda0fae675
8 changed files with 79 additions and 42 deletions

View File

@@ -46,6 +46,8 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// https://www.obj-sys.com/asn1tutorial/node128.html
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

View File

@@ -1519,11 +1519,14 @@ int tls_record_do_recv(uint8_t *record, size_t *recordlen, int sock)
int type;
size_t len;
// TODO支持非租塞socket或针对可能的网络延迟重新recv
if ((r = recv(sock, record, 5, 0)) < 0) {
perror("");
error_print();
return -1;
len = 5;
while (len) {
if ((r = recv(sock, record + 5 - len, len, 0)) < 0) {
perror("");
error_print();
return -1;
}
len -= r;
}
if (!tls_record_type_name(tls_record_type(record))) {
error_print();
@@ -1540,16 +1543,13 @@ int tls_record_do_recv(uint8_t *record, size_t *recordlen, int sock)
error_print();
return -1;
}
if (len) {
if ((r = recv(sock, record + 5, len, 0)) < 0) {
error_print();
return -1;
} else if (r != len) {
// FIXME: 不一定能够一次读取全部数据需要修正这个bug
fprintf(stderr, "%s %d: r = %zu, len = %zu\n", __FILE__, __LINE__, r, len);
while (len) {
if ((r = recv(sock, record + *recordlen - len, len, 0)) < 0) {
perror("");
error_print();
return -1;
}
len -= r;
}
return 1;
}

View File

@@ -46,12 +46,6 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
## TODO:
1. 每次发布时,应该将当前的时间戳添加到版本中
2. 将编译信息加入到版本的全部信息中,特别是发布二进制版专有功能时
*/
#include <gmssl/version.h>