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