mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Avoid snprintf in mruby-io test; ref #4981
This commit is contained in:
@@ -77,22 +77,21 @@ static int mrb_io_socket_available()
|
||||
struct sockaddr_un sun0;
|
||||
char socketname[] = "tmp.mruby-io-socket-ok.XXXXXXXX";
|
||||
if (!(fd = mkstemp(socketname))) {
|
||||
retval = 0;
|
||||
goto sock_test_out;
|
||||
}
|
||||
unlink(socketname);
|
||||
close(fd);
|
||||
fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd == -1) {
|
||||
retval = 0;
|
||||
goto sock_test_out;
|
||||
}
|
||||
sun0.sun_family = AF_UNIX;
|
||||
snprintf(sun0.sun_path, sizeof(sun0.sun_path), "%s", socketname);
|
||||
strncpy(sun0.sun_path, socketname, sizeof(sun0.sun_path));
|
||||
if (bind(fd, (struct sockaddr *)&sun0, sizeof(sun0)) == -1) {
|
||||
retval = 0;
|
||||
}
|
||||
sock_test_out:
|
||||
retval = 0;
|
||||
unlink(socketname);
|
||||
close(fd);
|
||||
return retval;
|
||||
|
||||
Reference in New Issue
Block a user