mirror of
https://github.com/jedisct1/minisign.git
synced 2025-04-05 11:57:40 +03:00
Merge pull request #35 from ulidtko/fix-broken-mkdir
fix "new.key: Is a directory" and a memleak when generating a keypair
This commit is contained in:
commit
f384177a3a
1 changed files with 6 additions and 2 deletions
|
@ -206,7 +206,11 @@ basedir_create_useronly(const char *file)
|
||||||
|
|
||||||
dir = xstrdup(file);
|
dir = xstrdup(file);
|
||||||
basename = file_basename(dir);
|
basename = file_basename(dir);
|
||||||
if (basename != dir) {
|
if (basename == dir) {
|
||||||
|
// this is a plain file path relative to CWD
|
||||||
|
free(dir);
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
dir[basename - dir - 1] = 0;
|
dir[basename - dir - 1] = 0;
|
||||||
}
|
}
|
||||||
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
|
||||||
|
@ -217,8 +221,8 @@ basedir_create_useronly(const char *file)
|
||||||
if (*dir == 0 || _mkdir(dir) == 0 || errno == EEXIST) {
|
if (*dir == 0 || _mkdir(dir) == 0 || errno == EEXIST) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
}
|
}
|
||||||
free(dir);
|
|
||||||
#endif
|
#endif
|
||||||
|
free(dir);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue