Fix a crash while trying to read nodes on amd64, reported in PR/41494,

by not doing any transfert when offset exceed the actual data length.

From and ok by pooka@.
This commit is contained in:
njoly 2009-05-28 10:07:06 +00:00
parent 53b002f1fb
commit 4c9ac951c7

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysctlfs.c,v 1.10 2009/01/18 10:10:47 lukem Exp $ */
/* $NetBSD: sysctlfs.c,v 1.11 2009/05/28 10:07:06 njoly Exp $ */
/*
* Copyright (c) 2006, 2007 Antti Kantee. All Rights Reserved.
@ -33,7 +33,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: sysctlfs.c,v 1.10 2009/01/18 10:10:47 lukem Exp $");
__RCSID("$NetBSD: sysctlfs.c,v 1.11 2009/05/28 10:07:06 njoly Exp $");
#endif /* !lint */
#include <sys/types.h>
@ -627,7 +627,10 @@ sysctlfs_node_read(struct puffs_usermount *pu, void *opc, uint8_t *buf,
return EISDIR;
doprint(sfs, &pn->pn_po, localbuf, sizeof(localbuf));
xfer = MIN(*resid, strlen(localbuf) - offset);
if (strlen(localbuf) < offset)
xfer = 0;
else
xfer = MIN(*resid, strlen(localbuf) - offset);
if (xfer <= 0)
return 0;