Skip to content

Commit

Permalink
Fix error in ad_openat(), bug #532
Browse files Browse the repository at this point in the history
Saving from Word to a folder that is a symlink to a folder on another filesystem
results in a crash of the afpd process and the save to fail. This happens only
if the option "follow symlinks" is enabled.
  • Loading branch information
slowfranklin committed Oct 8, 2013
1 parent 418235a commit 79f0b2f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions NEWS
Expand Up @@ -11,6 +11,10 @@ Changes in 3.0.6
* FIX: Small fix in the DSI tickle handling. Bug #528.
* UPD: Enhance handling of connection attempts when hitting the
connection limit. Bug #529.
* FIX: Saving from Word to a folder that is a symlink to a folder on
another filesystem results in a crash of the afpd process and
the save to fail. This happens only if the option
"follow symlinks" is enabled. Bug #532.

Changes in 3.0.5
================
Expand Down
6 changes: 5 additions & 1 deletion libatalk/adouble/ad_open.c
Expand Up @@ -1897,17 +1897,21 @@ int ad_openat(struct adouble *ad,
mode_t mode = 0;

if (dirfd != -1) {
if ((cwdfd = open(".", O_RDONLY) == -1) || (fchdir(dirfd) != 0))
if (((cwdfd = open(".", O_RDONLY)) == -1) || (fchdir(dirfd) != 0))
EC_FAIL;
}

LOG(log_note, logtype_ad, "ad_openat: cwdfd: %d", cwdfd);

va_start(args, adflags);
if (adflags & ADFLAGS_CREATE)
mode = (sizeof(mode_t) < sizeof(int) ? va_arg (args, int) : va_arg (args, mode_t));
va_end(args);

EC_NEG1( ad_open(ad, path, adflags, mode) );

LOG(log_note, logtype_ad, "ad_openat: cwdfd: %d", cwdfd);

if (dirfd != -1) {
if (fchdir(cwdfd) != 0) {
AFP_PANIC("ad_openat: cant chdir back");
Expand Down

0 comments on commit 79f0b2f

Please sign in to comment.