Thumbnail

rani/cscroll.git

Clone URL: https://git.buni.party/rani/cscroll.git

commit e136f4012ac2c282bf384c3cde4231c02da50ae1 Author: Raniconduh <clagv.randomgames@gmail.com> Date: Tue Oct 18 21:51:27 2022 +0000 use realpath() on homedir diff --git a/src/dir.c b/src/dir.c index 6cf66f4..bd4e07e 100644 --- a/src/dir.c +++ b/src/dir.c @@ -34114 +34111 @@ bool check_dpath(char * s) {  void get_home(void) {   char * s = getenv("HOME");   // check if var exists & is a real dir - if (s && *s && check_dpath(s)) { - homedir_len = strlen(s); - homedir = malloc(homedir_len + 1); - strcpy(homedir, s); - } else { // no var or empty + if (!s || *s == '\0' || !check_dpath(s)) {   struct passwd * pw = getpwuid(geteuid()); - homedir_len = strlen(pw->pw_dir); - homedir = malloc(homedir_len + 1); - strcpy(homedir, pw->pw_dir); + s = pw->pw_dir;   } + + homedir = realpath(s, NULL); + homedir_len = strlen(homedir);  }