From 3f2ba7d4239dab12746294f235a291ec124c25a2 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Thu, 31 Mar 2005 21:59:42 +0000 Subject: [PATCH] * amd/nfs_subr.c (fh_to_mp3): strncpy may not null terminate if copying exactly len bytes, so add null just to be safe. the memset can be removed because strncpy() should padd the --- ChangeLog | 7 ++++++- amd/nfs_subr.c | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ba95af5..efc105c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2005-03-31 Erez Zadok + + * amd/nfs_subr.c (fh_to_mp3): strncpy may not null terminate if + copying exactly len bytes, so add null just to be safe. + 2005-03-30 Daniel P. Ottavio * amd/nfs_subr.c (fh_to_mp3): Increased the n of strncpy() @@ -6,7 +11,7 @@ 2005-03-29 Daniel P. Ottavio * amd/nfs_subr.c (fh_to_mp3): Fix memset bug. In this case - the memset can be removed because strncpy() should padd the + the memset can be removed because strncpy() should padd the buffer with NULLs anyway. 2005-03-21 Rainer Orth diff --git a/amd/nfs_subr.c b/amd/nfs_subr.c index c298866..a4ec4f4 100644 --- a/amd/nfs_subr.c +++ b/amd/nfs_subr.c @@ -37,7 +37,7 @@ * SUCH DAMAGE. * * - * $Id: nfs_subr.c,v 1.25 2005/03/30 13:48:33 ottavio Exp $ + * $Id: nfs_subr.c,v 1.26 2005/03/31 21:59:43 ezk Exp $ * */ @@ -614,8 +614,10 @@ fh_to_mp3(am_nfs_fh *fhp, int *rp, int vop) if (fp->fhh_type != 0) { /* New filehandle type */ - char *path = xmalloc(sizeof(*fhp) + 1); - strncpy(path, (char *) fhp, sizeof(*fhp) + 1); + int len = sizeof(*fhp); + char *path = xmalloc(len + 1); + strncpy(path, (char *) fhp, len); + path[len+1] = '\0'; /* just to be safe */ /* dlog("fh_to_mp3: new filehandle: %s", path); */ ap = path_to_exported_ap(path); -- 2.43.0