You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
1.1 KiB

  1. From 6010c0303a422a9c5fa8860c061bf7105eb7f8b2 Mon Sep 17 00:00:00 2001
  2. From: "djm@openbsd.org" <djm@openbsd.org>
  3. Date: Fri, 16 Nov 2018 03:03:10 +0000
  4. Subject: [PATCH] upstream: disallow empty incoming filename or ones that refer
  5. to the
  6. current directory; based on report/patch from Harry Sintonen
  7. OpenBSD-Commit-ID: f27651b30eaee2df49540ab68d030865c04f6de9
  8. ---
  9. scp.c | 5 +++--
  10. 1 file changed, 3 insertions(+), 2 deletions(-)
  11. diff --git a/scp.c b/scp.c
  12. index 60682c687..4f3fdcd3d 100644
  13. --- a/scp.c
  14. +++ b/scp.c
  15. @@ -1,4 +1,4 @@
  16. -/* $OpenBSD: scp.c,v 1.197 2018/06/01 04:31:48 dtucker Exp $ */
  17. +/* $OpenBSD: scp.c,v 1.198 2018/11/16 03:03:10 djm Exp $ */
  18. /*
  19. * scp - secure remote copy. This is basically patched BSD rcp which
  20. * uses ssh to do the data transfer (instead of using rcmd).
  21. @@ -1106,7 +1106,8 @@ sink(int argc, char **argv)
  22. SCREWUP("size out of range");
  23. size = (off_t)ull;
  24. - if ((strchr(cp, '/') != NULL) || (strcmp(cp, "..") == 0)) {
  25. + if (*cp == '\0' || strchr(cp, '/') != NULL ||
  26. + strcmp(cp, ".") == 0 || strcmp(cp, "..") == 0) {
  27. run_err("error: unexpected filename: %s", cp);
  28. exit(1);
  29. }