File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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" ;
You can’t perform that action at this time.
0 commit comments