From: djm Date: Sat, 8 Jan 2022 07:37:32 +0000 (+0000) Subject: use status error message to communicate ~user expansion failures; X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=38bc52e08c63266ac51d811eb76e80f19bc968b5;p=openbsd use status error message to communicate ~user expansion failures; provides better experience for scp in sftp mode, where ~user paths are more likely to be used; spotted jsg, feedback jsg & deraadt ok jsg & markus --- diff --git a/usr.bin/ssh/sftp-client.c b/usr.bin/ssh/sftp-client.c index acea6babaf8..8eb5247a071 100644 --- a/usr.bin/ssh/sftp-client.c +++ b/usr.bin/ssh/sftp-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sftp-client.c,v 1.159 2022/01/08 07:34:57 djm Exp $ */ +/* $OpenBSD: sftp-client.c,v 1.160 2022/01/08 07:37:32 djm Exp $ */ /* * Copyright (c) 2001-2004 Damien Miller * @@ -989,10 +989,14 @@ do_realpath_expand(struct sftp_conn *conn, const char *path, int expand) if (type == SSH2_FXP_STATUS) { u_int status; + char *errmsg; - if ((r = sshbuf_get_u32(msg, &status)) != 0) + if ((r = sshbuf_get_u32(msg, &status)) != 0 || + (r = sshbuf_get_cstring(msg, &errmsg, NULL)) != 0) fatal_fr(r, "parse status"); - error("canonicalize %s: %s", path, fx2txt(status)); + error("%s %s: %s", expand ? "expand" : "realpath", + path, *errmsg == '\0' ? fx2txt(status) : errmsg); + free(errmsg); sshbuf_free(msg); return NULL; } else if (type != SSH2_FXP_NAME)