Skip to content

Commit

Permalink
Fix dangling symlinks handling
Browse files Browse the repository at this point in the history
When umtp encounters a directory with a dangling symlink, it would
wrongly presume an access issue, log and error:
MTP_OPERATION_GET_OBJECT_HANDLES : FOLDER ACCESS ERROR !
and the host/client would throw an "Input/output error" at the user.

The fix is rather straight-forward: have the "fs_find_first_file"
actually iterate over the entries returned by "readdir", and not just
stop at the (possibly broken) first.

Also log the error as PRINT_WARNING in the daemon's log output, so
that a user can diagnose&fix the issue.

Signed-off-by: Johannes Schneider <johannes.schneider@leica-geosystems.com>
  • Loading branch information
js731ca committed Sep 7, 2024
1 parent 7d7d099 commit 2aa07db
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/fs_handles_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <stdio.h>
#include <sys/stat.h>
#include <dirent.h>
#include <errno.h>

#include "mtp.h"
#include "mtp_helpers.h"
Expand Down Expand Up @@ -139,6 +140,10 @@ int fs_entry_stat(char *path, filefoundinfo* fileinfo)
return 1;
}

PRINT_WARN("stat64(%s) error: %s",path, strerror(errno));
fileinfo->size = 0;
fileinfo->filename[0] = '\0';

return 0;
}

Expand All @@ -151,8 +156,7 @@ DIR * fs_find_first_file(char *folder, filefoundinfo* fileinfo)
dir = opendir (folder);
if( dir )
{
d = readdir (dir);
if( d )
while ((d = readdir (dir)) != NULL)
{
tmpstr = malloc (strlen(folder) + strlen(d->d_name) + 4 );
if( tmpstr )
Expand Down

0 comments on commit 2aa07db

Please sign in to comment.