From 33647b904ebdc0555f40328d2e8b3905181e90c1 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Tue, 28 Apr 2020 18:30:50 +0900 Subject: Avoid `snprintf` in `mruby-io` test; ref #4981 --- mrbgems/mruby-io/test/mruby_io_test.c | 5 ++--- 1 file 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; -- cgit v1.2.3