diff options
author | Markus Friedl <markus@cvs.openbsd.org> | 2001-05-12 19:53:14 +0000 |
---|---|---|
committer | Markus Friedl <markus@cvs.openbsd.org> | 2001-05-12 19:53:14 +0000 |
commit | 7943beacaf964ed4004bc56762890e11a76f0ad6 (patch) | |
tree | 2b73147515b9cdee4aa2f17176d6add8995a1325 /usr.bin | |
parent | 4d2f695b7bf3f6a659bb807185b0b6a11ca72832 (diff) |
readlink does not NULL-terminate; mhe@home.se
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/ssh/sftp-server.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/usr.bin/ssh/sftp-server.c b/usr.bin/ssh/sftp-server.c index b49f8614f27..d26ef239c93 100644 --- a/usr.bin/ssh/sftp-server.c +++ b/usr.bin/ssh/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" @@ -863,18 +863,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); |