mruby-socket/socket.c (mrb_addrinfo_unix_path): check sockaddr type

`sockaddr` should be a string; fix #6051
This commit is contained in:
Yukihiro "Matz" Matsumoto
2023-09-16 23:55:16 +09:00
parent 40f08e22f1
commit 52082ba399
+1 -1
View File
@@ -214,7 +214,7 @@ mrb_addrinfo_unix_path(mrb_state *mrb, mrb_value self)
mrb_value sastr;
sastr = mrb_iv_get(mrb, self, MRB_IVSYM(sockaddr));
if (((struct sockaddr*)RSTRING_PTR(sastr))->sa_family != AF_UNIX)
if (!mrb_string_p(sastr) || ((struct sockaddr*)RSTRING_PTR(sastr))->sa_family != AF_UNIX)
mrb_raise(mrb, E_SOCKET_ERROR, "need AF_UNIX address");
if (RSTRING_LEN(sastr) < (mrb_int)offsetof(struct sockaddr_un, sun_path) + 1) {
return mrb_str_new(mrb, "", 0);