Changeset c9a6e18 in git


Ignore:
Timestamp:
29/06/19 03:07:43 (3 months ago)
Author:
Olly Betts <olly@…>
Branches:
master
Children:
9fe70e44
Parents:
41cd172
git-author:
Olly Betts <olly@…> (29/06/19 03:06:19)
git-committer:
Olly Betts <olly@…> (29/06/19 03:07:43)
Message:

Dereference symlinks when testing for file/directory

The code was carefully using lstat() where available to try to do
this, but that's backwards - regular stat() dereferences a symlink
and lstat() doesn't!

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • configure.ac

    r41cd172 rc9a6e18  
    252252dnl check for strcasecmp here as well as below - this one is to get
    253253dnl HAVE_STRCASECMP defined if appropriate (for img.c)
    254 AC_CHECK_FUNCS([popen getpwuid lround strcasecmp hypot lstat mmap])
     254AC_CHECK_FUNCS([popen getpwuid lround strcasecmp hypot mmap])
    255255
    256256dnl difftime seems to be an ANSI invention
  • src/message.c

    r41cd172 rc9a6e18  
    937937          * share directory and the binaries in the same directory. */
    938938         p = use_path(pth, "share/survex/en.msg");
    939          if (lstat(p, &buf) == 0 && S_ISREG(buf.st_mode)) {
     939         if (stat(p, &buf) == 0 && S_ISREG(buf.st_mode)) {
    940940            pth_cfg_files = use_path(pth, "share/survex");
    941941            msg_macosx_relocatable = 1;
     
    949949          */
    950950         p = use_path(pth, "../Resources/en.msg");
    951          if (lstat(p, &buf) == 0 && S_ISREG(buf.st_mode)) {
     951         if (stat(p, &buf) == 0 && S_ISREG(buf.st_mode)) {
    952952            pth_cfg_files = use_path(pth, "../Resources");
    953953            msg_macosx_relocatable = 1;
     
    961961          * tree easily. */
    962962         p = use_path(pth, "../lib/en.msg");
    963          if (lstat(p, &buf) == 0) {
     963         if (stat(p, &buf) == 0) {
    964964#ifdef S_ISREG
    965965            /* POSIX way */
  • src/osdepend.c

    r41cd172 rc9a6e18  
    7272#endif
    7373       ) return 1;
    74 #ifdef HAVE_LSTAT
    75    /* On Unix, dereference any symlinks we might encounter */
    76    if (lstat(fnm, &buf) != 0) return 0;
    77 #else
    7874   if (stat(fnm, &buf) != 0) return 0;
    79 #endif
    8075#ifdef S_ISDIR
    8176   /* POSIX way */
Note: See TracChangeset for help on using the changeset viewer.