DragonFlyBSD Kernel Audit
DF-0806 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/dirfs/dirfs_vnops.c b/sys/vfs/dirfs/dirfs_vnops.c
--- a/sys/vfs/dirfs/dirfs_vnops.c
+++ b/sys/vfs/dirfs/dirfs_vnops.c
@@ -1325,12 +1325,12 @@
 
 	pathnp = dirfs_findfd(dmp, dnp, &tmp, &pathfree);
 
-	buf = kmalloc(uio->uio_resid, M_DIRFS_MISC, M_WAITOK | M_ZERO);
+	buf = kmalloc(uio->uio_resid + 1, M_DIRFS_MISC, M_WAITOK | M_ZERO);
 	nlen = readlinkat(pathnp->dn_fd, dnp->dn_name, buf, uio->uio_resid);
 	if (nlen == -1 ) {
 		error = errno;
 	} else {
-		error = uiomove(buf, nlen + 1, uio);
+		error = uiomove(buf, nlen, uio);
 		buf[nlen] = '\0';
 		if (error)
 			error = errno;