| @@ -1,33 +1,33 @@ | | | @@ -1,33 +1,33 @@ |
1 | /* $NetBSD: sftp.c,v 1.37 2023/07/26 17:58:15 christos Exp $ */ | | 1 | /* $NetBSD: sftp.c,v 1.38 2023/07/28 04:52:23 rin Exp $ */ |
2 | /* $OpenBSD: sftp.c,v 1.229 2023/03/12 09:41:18 dtucker Exp $ */ | | 2 | /* $OpenBSD: sftp.c,v 1.229 2023/03/12 09:41:18 dtucker Exp $ */ |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> | | 4 | * Copyright (c) 2001-2004 Damien Miller <djm@openbsd.org> |
5 | * | | 5 | * |
6 | * Permission to use, copy, modify, and distribute this software for any | | 6 | * Permission to use, copy, modify, and distribute this software for any |
7 | * purpose with or without fee is hereby granted, provided that the above | | 7 | * purpose with or without fee is hereby granted, provided that the above |
8 | * copyright notice and this permission notice appear in all copies. | | 8 | * copyright notice and this permission notice appear in all copies. |
9 | * | | 9 | * |
10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 11 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 12 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 13 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 14 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 15 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 16 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
17 | */ | | 17 | */ |
18 | | | 18 | |
19 | #include "includes.h" | | 19 | #include "includes.h" |
20 | __RCSID("$NetBSD: sftp.c,v 1.37 2023/07/26 17:58:15 christos Exp $"); | | 20 | __RCSID("$NetBSD: sftp.c,v 1.38 2023/07/28 04:52:23 rin Exp $"); |
21 | | | 21 | |
22 | #include <sys/param.h> /* MIN MAX */ | | 22 | #include <sys/param.h> /* MIN MAX */ |
23 | #include <sys/types.h> | | 23 | #include <sys/types.h> |
24 | #include <sys/ioctl.h> | | 24 | #include <sys/ioctl.h> |
25 | #include <sys/wait.h> | | 25 | #include <sys/wait.h> |
26 | #include <sys/stat.h> | | 26 | #include <sys/stat.h> |
27 | #include <sys/socket.h> | | 27 | #include <sys/socket.h> |
28 | #include <sys/statvfs.h> | | 28 | #include <sys/statvfs.h> |
29 | | | 29 | |
30 | #include <ctype.h> | | 30 | #include <ctype.h> |
31 | #include <errno.h> | | 31 | #include <errno.h> |
32 | #include <glob.h> | | 32 | #include <glob.h> |
33 | #include <histedit.h> | | 33 | #include <histedit.h> |
| @@ -2009,27 +2009,27 @@ complete_match(EditLine *el, struct sftp | | | @@ -2009,27 +2009,27 @@ complete_match(EditLine *el, struct sftp |
2009 | xasprintf(&tmp, "%s*", file); | | 2009 | xasprintf(&tmp, "%s*", file); |
2010 | | | 2010 | |
2011 | /* Check if the path is absolute. */ | | 2011 | /* Check if the path is absolute. */ |
2012 | isabs = path_absolute(tmp); | | 2012 | isabs = path_absolute(tmp); |
2013 | | | 2013 | |
2014 | memset(&g, 0, sizeof(g)); | | 2014 | memset(&g, 0, sizeof(g)); |
2015 | if (remote != LOCAL) { | | 2015 | if (remote != LOCAL) { |
2016 | tmp2 = make_absolute_pwd_glob(tmp, remote_path); | | 2016 | tmp2 = make_absolute_pwd_glob(tmp, remote_path); |
2017 | free(tmp); | | 2017 | free(tmp); |
2018 | tmp = tmp2; | | 2018 | tmp = tmp2; |
2019 | remote_glob(conn, tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); | | 2019 | remote_glob(conn, tmp, GLOB_DOOFFS|GLOB_MARK, NULL, &g); |
2020 | } else | | 2020 | } else |
2021 | glob(tmp, GLOB_LIMIT|GLOB_DOOFFS|GLOB_MARK, NULL, &g); | | 2021 | glob(tmp, GLOB_LIMIT|GLOB_DOOFFS|GLOB_MARK, NULL, &g); |
2022 | | | 2022 | |
2023 | /* Determine length of pwd so we can trim completion display */ | | 2023 | /* Determine length of pwd so we can trim completion display */ |
2024 | for (hadglob = tmplen = pwdlen = 0; tmp[tmplen] != 0; tmplen++) { | | 2024 | for (hadglob = tmplen = pwdlen = 0; tmp[tmplen] != 0; tmplen++) { |
2025 | /* Terminate counting on first unescaped glob metacharacter */ | | 2025 | /* Terminate counting on first unescaped glob metacharacter */ |
2026 | if (tmp[tmplen] == '*' || tmp[tmplen] == '?') { | | 2026 | if (tmp[tmplen] == '*' || tmp[tmplen] == '?') { |
2027 | if (tmp[tmplen] != '*' || tmp[tmplen + 1] != '\0') | | 2027 | if (tmp[tmplen] != '*' || tmp[tmplen + 1] != '\0') |
2028 | hadglob = 1; | | 2028 | hadglob = 1; |
2029 | break; | | 2029 | break; |
2030 | } | | 2030 | } |
2031 | if (tmp[tmplen] == '\\' && tmp[tmplen + 1] != '\0') | | 2031 | if (tmp[tmplen] == '\\' && tmp[tmplen + 1] != '\0') |
2032 | tmplen++; | | 2032 | tmplen++; |
2033 | if (tmp[tmplen] == '/') | | 2033 | if (tmp[tmplen] == '/') |
2034 | pwdlen = tmplen + 1; /* track last seen '/' */ | | 2034 | pwdlen = tmplen + 1; /* track last seen '/' */ |
2035 | } | | 2035 | } |