all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Piotr Wasik <piotr.wasik@gmail.com>
To: 21808@debbugs.gnu.org
Subject: bug#21808: 24.3; tramp sorting with regular expression crashes whole dir listing
Date: Sun, 1 Nov 2015 15:49:12 +0000	[thread overview]
Message-ID: <CAGgdw2r5VmiHPRnPhCk+sssL=nj4FBrmn8dVzi=3kKH23uCoBg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1786 bytes --]

hi,

I try to set up tramp with adb to access nexus. Its root directory contains
a protected file called factory and directory listing returns: "lstat
'//factory' failed: Permission denied" as one of files.

it crashes with the following backtrace
;; Debugger entered--Lisp error: (args-out-of-range "lstat '//factory'
failed: Permission denied" 55 43)
;;   tramp-adb-ls-output-name-less-p("lstat '//factory' failed: Permission
denied" "lrwxrwxrwx root     root            0 2015-11-01 13:49 etc ->
/system/etc")
;;   sort(("drwxr-xr-x root     root            0 2015-11-01 13:49 acct"
"drwxrwx--- system   cache           0 2015-11-01 15:03 cache" "lrwxrwxrwx
root     root            0 1970-01-01 01:00 charger -> /sbin/healthd"
"dr-x------ root     root            0 2015-11-01 13:49 config" "lrwxrwxrwx
root     root            0 2015-11-01 13:49 d -> /sys/kernel/debug")
tramp-adb-ls-output-name-less-p)
;;   tramp-adb-sh-fix-ls-output()
;;   tramp-adb-handle-directory-files-and-attributes("/adb::/")
;;   eval((tramp-adb-handle-directory-files-and-attributes "/adb::/") nil)
;;   eval-last-sexp-1(t)
;;   eval-last-sexp(t)
;;   eval-print-last-sexp()
;;   call-interactively(eval-print-last-sexp nil nil)

I suggest a fix:

(defun tramp-adb-ls-output-name-less-p (a b)
  "Sort \"ls\" output by name, ascending."
  (let (posa posb matched-a matched-b)
    (setq matched-a (string-match dired-move-to-filename-regexp a))
    (setq posa (match-end 0))
    (setq matched-b (string-match dired-move-to-filename-regexp b))
    (setq posb (match-end 0))
    (string-lessp (substring a (if matched-a a 0)) (substring b (if
matched-b b 0)))))

I added matched-a and matched-b variables so even if directory listing
returns something unexpected, sorting completes normally.

Cheers,
Piotr

[-- Attachment #2: Type: text/html, Size: 2400 bytes --]

             reply	other threads:[~2015-11-01 15:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-01 15:49 Piotr Wasik [this message]
2015-11-01 19:26 ` bug#21808: Fixed in master Jürgen Hötzel
2015-11-01 22:26 ` bug#21808: 24.3; tramp sorting with regular expression crashes whole dir listing Michael Albinus
     [not found]   ` <CAGgdw2o+vXDp3hP1Vky7_4aMWO4SxERaEABn=c__4KyV9XUmuw@mail.gmail.com>
2015-11-01 22:37     ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGgdw2r5VmiHPRnPhCk+sssL=nj4FBrmn8dVzi=3kKH23uCoBg@mail.gmail.com' \
    --to=piotr.wasik@gmail.com \
    --cc=21808@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.