projects
/
sxemacs
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
6078798
)
Coverity: TOCTOU: CID 392
author
Nelson Ferreira
<nelson.ferreira@ieee.org>
Wed, 22 Feb 2012 23:38:13 +0000
(18:38 -0500)
committer
Nelson Ferreira
<nelson.ferreira@ieee.org>
Wed, 22 Feb 2012 23:38:13 +0000
(18:38 -0500)
* src/editfns.c (Ftemp_directory): First mkdir then properly
handle errors for the home directory temp directory creation.
Also attempt to create .created_by_sxemacs in case the dir exists.
Signed-off-by: Nelson Ferreira <nelson.ferreira@ieee.org>
src/editfns.c
patch
|
blob
|
history
diff --git
a/src/editfns.c
b/src/editfns.c
index
4e52585
..
089b7f4
100644
(file)
--- a/
src/editfns.c
+++ b/
src/editfns.c
@@
-619,12
+619,11
@@
On Unix it is obtained from TMPDIR, with /tmp as the default.
if ( home_env ) {
strncpy(path, home_env, sizeof(path)-1);
strncat(path, "/tmp/", sizeof(path)-1);
- if (
stat(path, &st) < 0 && errno == ENOENT
) {
+ if (
mkdir(path, 0700) >= 0 || errno == EEXIST
) {
int fd;
char warnpath[
/* strlen(".created_by_sxemacs") */
19 + _POSIX_PATH_MAX + 1];
- mkdir(path, 0700); /* ignore retvals */
strncpy(warnpath, path, _POSIX_PATH_MAX);
warnpath[sizeof(warnpath)-1]=0;