summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-io
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-04-28 18:30:50 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-10-12 16:20:43 +0900
commit33647b904ebdc0555f40328d2e8b3905181e90c1 (patch)
tree0a7fc77e5805cac5f0a360d9c841d40004d43705 /mrbgems/mruby-io
parent47f65a93c59f146d1e4d9b4d7145bdeead7a6397 (diff)
downloadmruby-33647b904ebdc0555f40328d2e8b3905181e90c1.tar.gz
mruby-33647b904ebdc0555f40328d2e8b3905181e90c1.zip
Avoid `snprintf` in `mruby-io` test; ref #4981
Diffstat (limited to 'mrbgems/mruby-io')
-rw-r--r--mrbgems/mruby-io/test/mruby_io_test.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/mrbgems/mruby-io/test/mruby_io_test.c b/mrbgems/mruby-io/test/mruby_io_test.c
index 7ad59d495..3a98820ae 100644
--- a/mrbgems/mruby-io/test/mruby_io_test.c
+++ b/mrbgems/mruby-io/test/mruby_io_test.c
@@ -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;