Kaleb KEITHLEY has uploaded this change for review.

View Change

coverity: string is not null terminated (do not merge)

Now with utf8string_dup(). But do not merge because this adds more
coverity warnings than it fixes.

Fixes an issue (of sorts) reported by coverity, namely not enough
memory is allocated to store a terminating NULL in a utf8string.

The warning is a false positive. utf8strings in ganesha are nominally
strings that come off the wire and may or may not be null terminated;
given that, it is not safe to call strlen(). Furthermore, they need
not be NULL terminated when stored internally as the length is stored
in an associated length variable.

In this case the string comes from an xattr and should contain a ':'
separator. The ':' separator, if there is one, is replaced with a null
by strsep(). By convention it should still be considered not safe to
call strlen() or (gsh_)strdup(), but gsh_strdup() is used everywhere
else in ganesha for utf8strings, so we do it here as well. Foolish
consistency and all that. At least we know it's safe here. And it
should silence the coverity warning.

Unfortunately simply adding a /* coverity[OVERRUN] */ comment here
did not silence it.

Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Change-Id: I3f1b3840022686d979421d267b6fc518e01fdd02
---
M src/FSAL/FSAL_VFS/subfsal_helpers.c
M src/MainNFSD/libganesha_nfsd.ver
M src/Protocols/NFS/nfs4_op_readdir.c
M src/Protocols/NFS/nfs_proto_tools.c
M src/include/nfsv41.h
5 files changed, 33 insertions(+), 14 deletions(-)

git pull ssh://review.gerrithub.io:29418/ffilz/nfs-ganesha refs/changes/87/458987/1

To view, visit change 458987. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: ffilz/nfs-ganesha
Gerrit-Branch: next
Gerrit-Change-Id: I3f1b3840022686d979421d267b6fc518e01fdd02
Gerrit-Change-Number: 458987
Gerrit-PatchSet: 1
Gerrit-Owner: Kaleb KEITHLEY <kaleb@redhat.com>
Gerrit-MessageType: newchange