From: Zbigniew Kostrzewa Date: Wed, 31 Jul 2013 06:16:50 +0000 (+0200) Subject: Prevent issue fix. X-Git-Tag: 2.2.1_release~2^2~16 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ff61b2af94ad7e78c1ff8093616466795f8966a4;p=framework%2Fweb%2Fwrt-plugins-common.git Prevent issue fix. [Issue#] #22995 [Problem] closedir() repeated if EINTR occurrs [Cause] For POSIX closedir() specifies two possible errno values: EBADF, EINTR (see closedir(3p)). For Linux, on the other hand, only one errno value is specified: EBADF (see closedir(3)). In fact, closedir() implementation in GNU C Library may set other errno values as well, e.g. EINVAL if value NULL is passed to the function (verified for glibc 2.15, source file sysdeps/unix/closedir.c). Assuming that closedir() is just a wrapper around a call to close() system call and having in mind that it was decided (and confirmed by Linus Torvalds) that repeating close() even for EINTR is unsafe I have decided to not repeat closedir() in such case as well. What's more, implementation of closedir() in GNU C Library calls free() on the stream handle so repeating closedir() may lead to memory corruption (as reported by Prevent). [Solution] Do not repeat closedir() on error (even EINTR). [SCMRequest] N/A [Verification] Build repository. Change-Id: I7257b532dac19ae5b8485c5449d8e93c36364243 --- diff --git a/src/plugins-installer/plugin_installer.cpp b/src/plugins-installer/plugin_installer.cpp index 44bce08..645bc72 100644 --- a/src/plugins-installer/plugin_installer.cpp +++ b/src/plugins-installer/plugin_installer.cpp @@ -418,7 +418,7 @@ int PluginsInstaller::installAllPlugins() if (0 != return_code) LogError("Error while reading directory."); - if (-1 == TEMP_FAILURE_RETRY(closedir(dir))) { + if (-1 == closedir(dir)) { LogError("Failed to close dir: " << PLUGIN_PATH); }