Message ID | bce2b57b-50c8-0b56-b42d-9ff357c26eb6@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xfsprogs: minor 4.20 fixups | expand |
On Tue, Feb 19, 2019 at 05:33:46PM -0600, Eric Sandeen wrote: > I had a heck of a time chasing through whether we were null terminated > by now or not, so just be safe and do it explicitly. > > Addresses-Coverity-ID: 1297520 ("Buffer not null terminated") > Signed-off-by: Eric Sandeen <sandeen@redhat.com> Looks ok, Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> --D > --- > > diff --git a/libhandle/handle.c b/libhandle/handle.c > index eb099f4..d3927a3 100644 > --- a/libhandle/handle.c > +++ b/libhandle/handle.c > @@ -108,6 +108,7 @@ path_to_fshandle( > > fdhp->fsfd = fd; > strncpy(fdhp->fspath, fspath, sizeof(fdhp->fspath)); > + fdhp->fspath[sizeof(fdhp->fspath) - 1] = '\0'; > memcpy(fdhp->fsh, *fshanp, FSIDSIZE); > > fdhp->fnxt = fdhash_head; >
diff --git a/libhandle/handle.c b/libhandle/handle.c index eb099f4..d3927a3 100644 --- a/libhandle/handle.c +++ b/libhandle/handle.c @@ -108,6 +108,7 @@ path_to_fshandle( fdhp->fsfd = fd; strncpy(fdhp->fspath, fspath, sizeof(fdhp->fspath)); + fdhp->fspath[sizeof(fdhp->fspath) - 1] = '\0'; memcpy(fdhp->fsh, *fshanp, FSIDSIZE); fdhp->fnxt = fdhash_head;
I had a heck of a time chasing through whether we were null terminated by now or not, so just be safe and do it explicitly. Addresses-Coverity-ID: 1297520 ("Buffer not null terminated") Signed-off-by: Eric Sandeen <sandeen@redhat.com> ---