#! /bin/sh /usr/share/dpatch/dpatch-run ## 102-unittest.dpatch by Andreas Putzo ## ## DP: Use mkdtemp to avoid a potential symlink attack. @DPATCH@ diff -urNad gpsdrive-2.10~pre4-6.dfsg~/src/unit_test.c gpsdrive-2.10~pre4-6.dfsg/src/unit_test.c --- gpsdrive-2.10~pre4-6.dfsg~/src/unit_test.c 2007-09-15 15:12:03.000000000 +0000 +++ gpsdrive-2.10~pre4-6.dfsg/src/unit_test.c 2008-12-29 15:33:26.000000000 +0000 @@ -649,10 +649,12 @@ gchar fn[500]; gint response; - - g_snprintf (dir_proc, sizeof (dir_proc), "/tmp/gpsdrive-unit-test"); - mkdir (dir_proc, 0777); - g_snprintf (dir_proc, sizeof (dir_proc), "/tmp/gpsdrive-unit-test/proc"); + strncpy(dir_proc, "/tmp/gpsdrive-unit-test.XXXXXX", sizeof(dir_proc)); + if (mkdtemp(dir_proc) == NULL) { + printf("Error: Faild to create temporary directory\n"); + exit(1); + } + strncat(dir_proc, "/proc", sizeof(dir_proc)); mkdir (dir_proc, 0777); if (mydebug > 0)