Skip to content

Commit

Permalink
MacOSX: Remove deprecated tmpnam call for OS X
Browse files Browse the repository at this point in the history
The following build errors can be seen for MacOSX builds:
.../osunixxf.c:829:42: error: 'tmpnam' is deprecated: This function is provided for compatibility reasons only.  Due to security concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead. [-Werror,-Wdeprecated-declarations]

tmpnam should NOT be used and provides an easy and obvious privilege
escalation attack point.  There is no advantage or compatibility reason to
use this function on OS X, and it correctly throws an error if its use is
attempted.  Simply replacing it with mktemp, which behaves identically to
tmpnam, only with responsible protection against interprocess attacks.  It
will behave identically if given NULL, and will fail in exactly the same
way, so there is no danger in switching to this function.

It's also safely tucked away in a specific #ifdef __APPLE__ block anyway,
so the scope of this change is perfectly controlled.

Signed-off-by: metacollin <metacollin@gmail.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
metacollin authored and Lv Zheng committed Sep 20, 2016
1 parent d14099f commit 01eb9a5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/os_specific/service_layers/osunixxf.c
Expand Up @@ -826,7 +826,7 @@ AcpiOsCreateSemaphore (

#ifdef __APPLE__
{
char *SemaphoreName = tmpnam (NULL);
char *SemaphoreName = mktemp (NULL);

Sem = sem_open (SemaphoreName, O_EXCL|O_CREAT, 0755, InitialUnits);
if (!Sem)
Expand Down

0 comments on commit 01eb9a5

Please sign in to comment.