diff options
author | Eduardo Chappa <chappa@washington.edu> | 2018-08-12 11:48:52 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2018-08-12 11:48:52 -0600 |
commit | abcd5fe37b31b2e13907893f70a9e411dcf5e295 (patch) | |
tree | 6bc093b14be33feb92f86bb65830804594c4011e /pith/conf.c | |
parent | 7f7ec82c7dc023b9ac7b985d1abe10e7bd3d908e (diff) | |
download | alpine-abcd5fe37b31b2e13907893f70a9e411dcf5e295.tar.xz |
* The call realpath(..., NULL) gives an error in Solaris, which means that
we need to allocate memory for storing the resolved path. Reported by
Fabian Schmidt.
Diffstat (limited to 'pith/conf.c')
-rw-r--r-- | pith/conf.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/pith/conf.c b/pith/conf.c index b75d8891..0085e955 100644 --- a/pith/conf.c +++ b/pith/conf.c @@ -5973,14 +5973,22 @@ write_pinerc(struct pine *ps, EditWhich which, int flags) if(so_give(&so)) goto io_err; #ifndef _WINDOWS - if ((realfilename = realpath(filename, NULL)) != NULL) - realfilename_malloced = 1; - else if(our_stat(filename, &sbuf) < 0 && errno == ENOENT){ - realfilename = filename; - realfilename_malloced = 0; + realfilename = fs_get(MAXPATH+1); + if(realfilename != NULL){ + if(realpath(filename, realfilename) == NULL) + fs_give((void **) &realfilename); + realfilename_malloced = realfilename != NULL ? 1 : 0; } else - goto io_err; + realfilename_malloced = 0; + if (realfilename_malloced == 0){ + if(our_stat(filename, &sbuf) < 0 && errno == ENOENT){ + realfilename = filename; + realfilename_malloced = 0; + } + else + goto io_err; + } #else realfilename = filename; realfilename_malloced = 0; @@ -5990,7 +5998,7 @@ write_pinerc(struct pine *ps, EditWhich which, int flags) file_attrib_copy(tmp, realfilename); r = rename_file(tmp, realfilename); if(realfilename_malloced != 0) - free((void *)realfilename); + fs_give((void **) &realfilename); if(r < 0) goto io_err; } } |