diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2014-04-22 20:35:57 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-04-22 20:35:57 -0300 |
commit | 823bdbae133afcb00718ab50af85186df2e7b155 (patch) | |
tree | 84aa29d254fe566a7db64df478b4787f215bcb6a /Settings.c | |
parent | 1afbc190872b72eaf8f2b3cb1efbbef5a0add268 (diff) |
safer code, check result of lstat
Diffstat (limited to 'Settings.c')
-rw-r--r-- | Settings.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -243,12 +243,14 @@ Settings* Settings_new(ProcessList* pl, Header* header, int cpuCount) { htopDir = String_cat(home, "/.config/htop"); } legacyDotfile = String_cat(home, "/.htoprc"); - mkdir(configDir, 0700); - mkdir(htopDir, 0700); + (void) mkdir(configDir, 0700); + (void) mkdir(htopDir, 0700); free(htopDir); free(configDir); struct stat st; - lstat(legacyDotfile, &st); + if (lstat(legacyDotfile, &st) != 0) { + st.st_mode = 0; + } if (access(legacyDotfile, R_OK) != 0 || S_ISLNK(st.st_mode)) { free(legacyDotfile); legacyDotfile = NULL; |