[Bug 271350] ftp(1) does not process file:// uris correctly

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 10 May 2023 12:55:52 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271350

            Bug ID: 271350
           Summary: ftp(1) does not process file:// uris correctly
           Product: Base System
           Version: 13.2-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: miod@online.fr

ftp(1) will enter an infinite loop when used in non-interactive mode with a
`file://' uri as argument.

This is caused by the `bufsize` local variable of `fetch_url()` in
`contrib/tnftp/src/fetch.c` being only set to a non-zero value when sockets are
created to fetch files from the network. Because of this, the
loop-until-all-the-contents-are-read starting on line 1215 always computes a
value of 0 for `bufrem`, does not perform any I/O, and basically spins hogging
the cpu.

How to reproduce:
$ cd /tmp && ftp file:///etc/passwd

Expected result:
copy of /etc/passwd in /tmp

Observed result:
progress bar at 0%, no ETA, one cpu spinning

Workaround:
Use fetch(1).

-- 
You are receiving this mail because:
You are the assignee for the bug.