Skip to content

Commit 9642d3b

Browse files
orbisai0securityzhaozg
authored andcommitted
fix: V-003 security vulnerability
Automated security fix generated by Orbis Security AI
1 parent 3ca998f commit 9642d3b

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/ssl.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1008,10 +1008,20 @@ openssl_ssl_ctx_set_alpn_protos(lua_State *L)
10081008
break;
10091009
}
10101010
if (proto_list_len + proto_len >= proto_list_size) {
1011+
unsigned char *tmp;
10111012
do {
1013+
if (proto_list_size > (size_t)(-1) / 2) {
1014+
free(proto_list);
1015+
return luaL_error(L, "protocol list too large");
1016+
}
10121017
proto_list_size = proto_list_size * 2;
10131018
} while (proto_list_len + proto_len >= proto_list_size);
1014-
proto_list = realloc(proto_list, proto_list_size);
1019+
tmp = realloc(proto_list, proto_list_size);
1020+
if (tmp == NULL) {
1021+
free(proto_list);
1022+
return luaL_error(L, "fail to allocate protocol list");
1023+
}
1024+
proto_list = tmp;
10151025
}
10161026
if (proto_list == NULL) {
10171027
err = "fail to allocate protocol list";

0 commit comments

Comments
 (0)