mirror of
https://github.com/openssh/openssh-portable.git
synced 2026-11-06 05:16:43 +00:00
upstream: avoid possible over-read when a SFTP READPATH operations
return a zero- length path. Patch from immortal-jelly <xuehaolin@uniontech.com> OpenBSD-Commit-ID: 4f30d7d378626d333d2718fefcb3e62d42777c34
This commit is contained in:
1 parent
538af298ad
commit
e4d03fbf92
1 file changed
+6
-1
+6
-1
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: sftp-realpath.c,v 1.2 2021/09/02 21:03:54 deraadt Exp $ */
|
||||
/* $OpenBSD: sftp-realpath.c,v 1.3 2026/10/29 04:41:59 djm Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2003 Constantin S. Svintsoff <kostik@iclub.nsu.ru>
|
||||
*
|
||||
@@ -173,6 +173,11 @@ sftp_realpath(const char *path, char *resolved)
|
||||
slen = readlink(resolved, symlink, sizeof(symlink) - 1);
|
||||
if (slen < 0)
|
||||
goto err;
|
||||
if (slen == 0) {
|
||||
/* refuse empty links */
|
||||
errno = ENOENT;
|
||||
goto err;
|
||||
}
|
||||
symlink[slen] = '\0';
|
||||
if (symlink[0] == '/') {
|
||||
resolved[1] = 0;
|
||||
|
||||
Reference in new issue
Block a user