From: Radoslaw Cybulski Date: Thu, 18 Apr 2019 10:26:46 +0000 (+0200) Subject: Fixes SVACE issue with thread-unsafe calls to strerror X-Git-Tag: accepted/tizen/unified/20190425.014541^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F09%2F204009%2F3;p=platform%2Fupstream%2Fat-spi2-core.git Fixes SVACE issue with thread-unsafe calls to strerror Calls to strerror were replaced with calls to strerror_r, which is thread-safe. Change-Id: I6ee4908672118248b96590f375005ee424daea85 --- diff --git a/bus/at-spi-bus-launcher.c b/bus/at-spi-bus-launcher.c index e42a26d..65bb0b1 100644 --- a/bus/at-spi-bus-launcher.c +++ b/bus/at-spi-bus-launcher.c @@ -349,7 +349,11 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path) argv[1] = (char*)config_path; if (pipe (app->pipefd) < 0) - g_error ("Failed to create pipe: %s", strerror (errno)); + { + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + g_error ("Failed to create pipe: %s", buf); + } g_clear_pointer (&app->a11y_launch_error_message, g_free); @@ -378,7 +382,9 @@ ensure_a11y_bus_daemon (A11yBusLauncher *app, char *config_path) LOGD("Launched a11y bus, child is %ld", (long) pid); if (!unix_read_all_fd_to_string (app->pipefd[0], addr_buf, sizeof (addr_buf))) { - app->a11y_launch_error_message = g_strdup_printf ("Failed to read address: %s", strerror (errno)); + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + app->a11y_launch_error_message = g_strdup_printf ("Failed to read address: %s", buf); kill (app->a11y_bus_pid, SIGTERM); goto error; } @@ -437,16 +443,32 @@ ensure_a11y_bus_broker (A11yBusLauncher *app, char *config_path) GError *error = NULL; if ((app->listenfd = socket (PF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0)) < 0) - g_error ("Failed to create listening socket: %s", strerror (errno)); + { + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + g_error ("Failed to create listening socket: %s", buf); + } if (bind (app->listenfd, (struct sockaddr *)&addr, sizeof(sa_family_t)) < 0) - g_error ("Failed to bind listening socket: %s", strerror (errno)); + { + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + g_error ("Failed to bind listening socket: %s", buf); + } if (getsockname (app->listenfd, (struct sockaddr *)&addr, &addr_len) < 0) - g_error ("Failed to get socket name for listening socket: %s", strerror(errno)); + { + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + g_error ("Failed to get socket name for listening socket: %s", buf); + } if (listen (app->listenfd, 1024) < 0) - g_error ("Failed to listen on socket: %s", strerror(errno)); + { + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + g_error ("Failed to listen on socket: %s", buf); + } g_clear_pointer (&app->a11y_launch_error_message, g_free); @@ -870,7 +892,11 @@ init_sigterm_handling (A11yBusLauncher *app) GIOChannel *sigterm_channel; if (pipe (sigterm_pipefd) < 0) - g_error ("Failed to create pipe: %s", strerror (errno)); + { + char buf[4096] = { 0 }; + strerror_r (errno, buf, sizeof(buf)); + g_error ("Failed to create pipe: %s", buf); + } signal (SIGTERM, sigterm_handler); sigterm_channel = g_io_channel_unix_new (sigterm_pipefd[0]);