From: Davidlohr Bueso <dave@xxxxxxx> The tmpnam(3) function presents a security hazard, so use mkstemp(3) instead. Even though this is a deprecated command, due to security reasons, we should address this problem. Signed-off-by: Davidlohr Bueso <dave@xxxxxxx> --- simpleinit/initctl.c | 17 ++++++++++++++--- 1 files changed, 14 insertions(+), 3 deletions(-) diff --git a/simpleinit/initctl.c b/simpleinit/initctl.c index 3b38b49..6258a36 100644 --- a/simpleinit/initctl.c +++ b/simpleinit/initctl.c @@ -49,6 +49,8 @@ #include <signal.h> #include <stdlib.h> #include <string.h> +#include <err.h> + #include "simpleinit.h" @@ -63,7 +65,7 @@ int main (int argc, char **argv) int fd, nbytes; struct sigaction sa; sigset_t ss; - char *ptr; + char *ptr, *tmp; long *buffer; struct command_struct *command; @@ -135,12 +137,21 @@ int main (int argc, char **argv) else command->name[0] = '\0'; break; case COMMAND_DUMP_LIST: - if (tmpnam (command->name) == NULL) - { + tmp = malloc(sizeof(char) * (strlen(command->name) + 8 )); + if (!tmp) + errx(EXIT_FAILURE, "cannot allocate memory\n"); + + sprintf(tmp, "%s-XXXXXX", command->name); + if (-1 == (fd = mkstemp(tmp))) { fprintf (stderr, "Unable to create a unique filename\t%s\n", ERRSTRING); exit (1); } + /* we don't use this file really */ + close(fd); + unlink(tmp); + free(tmp); + if (mkfifo (command->name, S_IRUSR) != 0) { fprintf (stderr, "Unable to create FIFO: \"%s\"\t%s\n", -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html