From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 4956 invoked from network); 19 Sep 2021 15:03:27 -0000 Received: from bsd.lv (HELO mandoc.bsd.lv) (66.111.2.12) by inbox.vuxu.org with ESMTPUTF8; 19 Sep 2021 15:03:27 -0000 Received: from fantadrom.bsd.lv (localhost [127.0.0.1]) by mandoc.bsd.lv (OpenSMTPD) with ESMTP id 130c9f17 for ; Sun, 19 Sep 2021 10:03:25 -0500 (EST) Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id 9fc398b5 for ; Sun, 19 Sep 2021 10:03:25 -0500 (EST) Date: Sun, 19 Sep 2021 10:03:25 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: Two minor improvements: 1. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- Two minor improvements: 1. If mktemp(3) fails, do not overwrite the errno because all errors mktemp(3) might return are also valid for mkdtemp(3). 2. If mkdir(2) fails, always put back the Xes, even if the error is fatal and the function is about to return NULL. Modified Files: -------------- mandoc: compat_mkdtemp.c Revision Data ------------- Index: compat_mkdtemp.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/compat_mkdtemp.c,v retrieving revision 1.3 retrieving revision 1.4 diff -Lcompat_mkdtemp.c -Lcompat_mkdtemp.c -u -p -r1.3 -r1.4 --- compat_mkdtemp.c +++ compat_mkdtemp.c @@ -1,6 +1,6 @@ /* $Id$ */ /* - * Copyright (c) 2015 Ingo Schwarze + * Copyright (c) 2015, 2021 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -36,16 +36,14 @@ mkdtemp(char *path) start--; for (tries = INT_MAX; tries; tries--) { - if (mktemp(path) == NULL) { - errno = EEXIST; + if (mktemp(path) == NULL) return NULL; - } if (mkdir(path, S_IRUSR | S_IWUSR | S_IXUSR) == 0) return path; - if (errno != EEXIST) - return NULL; for (cp = start; *cp != '\0'; cp++) *cp = 'X'; + if (errno != EEXIST) + return NULL; } errno = EEXIST; return NULL; -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv