Mailing List Archive

[Bug 3158] New: ssh-copy-id raises "expr: syntax error" when double-hyphen is passed ("--")
https://bugzilla.mindrot.org/show_bug.cgi?id=3158

Bug ID: 3158
Summary: ssh-copy-id raises "expr: syntax error" when
double-hyphen is passed ("--")
Product: Portable OpenSSH
Version: 8.2p1
Hardware: All
OS: Linux
Status: NEW
Severity: minor
Priority: P5
Component: ssh-copy-id
Assignee: unassigned-bugs@mindrot.org
Reporter: rf@rufflewind.com

Assuming an identity file exists at ~/.ssh/id_rsa.pub, the following
command, which adds a preventative double-dash ("--"):

ssh-copy-id -i ~/.ssh/id_rsa.pub -- remote-server

will result in the following error:

expr: syntax error: unexpected argument ā€˜[-]iā€™

The error is non-fatal, but it may be confusing to users.

I suspect this is caused by line 110:

[ "${SEEN_OPT_I}" ] && expr "$1" : "[-]i" >/dev/null && {

Here, "$1" is passed to expr without being validated, so if $1 is "--"
as shown in the command above, this will confuse expr. I think expr
should be called with "--" to prevent this:

[ "${SEEN_OPT_I}" ] && expr -- "$1" : "[-]i" >/dev/null && {

--
You are receiving this mail because:
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs