From abbb73d0893e2daf4a06339f581cbe7dc752260f Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Thu, 17 May 2001 03:14:57 +0000 Subject: - markus@cvs.openbsd.org 2001/05/12 19:53:13 [sftp-server.c] readlink does not NULL-terminate; mhe@home.se --- sftp-server.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sftp-server.c') diff --git a/sftp-server.c b/sftp-server.c index 75c19c8a..1cbd1847 100644 --- a/sftp-server.c +++ b/sftp-server.c @@ -22,7 +22,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "includes.h" -RCSID("$OpenBSD: sftp-server.c,v 1.25 2001/04/05 10:42:53 markus Exp $"); +RCSID("$OpenBSD: sftp-server.c,v 1.26 2001/05/12 19:53:13 markus Exp $"); #include "buffer.h" #include "bufaux.h" @@ -883,18 +883,19 @@ void process_readlink(void) { u_int32_t id; + int len; char link[MAXPATHLEN]; char *path; id = get_int(); path = get_string(NULL); TRACE("readlink id %d path %s", id, path); - if (readlink(path, link, sizeof(link) - 1) == -1) + if ((len = readlink(path, link, sizeof(link) - 1)) == -1) send_status(id, errno_to_portable(errno)); else { Stat s; - link[sizeof(link) - 1] = '\0'; + link[len] = '\0'; attrib_clear(&s.attrib); s.name = s.long_name = link; send_names(id, 1, &s); -- cgit v1.2.1