From 62e43541d730ae689710dbe1ddcd022866d67e72 Mon Sep 17 00:00:00 2001 From: Pawel Dziepak Date: Tue, 19 Mar 2013 00:33:46 +0100 Subject: [PATCH] nfs4: Fix wrong parenthesising in ReplyInterpreter::_FlattenPathname This patch solves CID 990966. --- .../kernel/file_systems/nfs4/ReplyInterpreter.cpp | 14 +++++++------- .../kernel/file_systems/nfs4/ReplyInterpreter.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp index 1dbcd8d3dd..644460edca 100644 --- a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp +++ b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.cpp @@ -522,17 +522,17 @@ ReplyInterpreter::Write(uint32* size) } -static const char* -sFlattenPathname(XDR::ReadStream& str) +const char* +ReplyInterpreter::_FlattenPathname(XDR::ReadStream& stream) { - uint32 count = str.GetUInt(); + uint32 count = stream.GetUInt(); char* pathname = NULL; uint32 size = 0; for (uint32 i = 0; i < count; i++) { - const char* path = str.GetString(); + const char* path = stream.GetString(); size += strlen(path) + 1; if (pathname == NULL) { - pathname = reinterpret_cast(malloc(strlen(path + 1))); + pathname = reinterpret_cast(malloc(strlen(path) + 1)); pathname[0] = '\0'; } else { *pathname++ = '/'; @@ -657,11 +657,11 @@ ReplyInterpreter::_DecodeAttrs(XDR::ReadStream& str, AttrValue** attrs, values[current].fAttribute = FATTR4_FS_LOCATIONS; FSLocations* locs = new FSLocations; - locs->fRootPath = sFlattenPathname(stream); + locs->fRootPath = _FlattenPathname(stream); locs->fCount = stream.GetUInt(); locs->fLocations = new FSLocation[locs->fCount]; for (uint32 i = 0; i < locs->fCount; i++) { - locs->fLocations[i].fRootPath = sFlattenPathname(stream); + locs->fLocations[i].fRootPath = _FlattenPathname(stream); locs->fLocations[i].fCount = stream.GetUInt(); locs->fLocations[i].fLocations = new const char*[locs->fLocations[i].fCount]; diff --git a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h index b630b8ffb9..654963ad4e 100644 --- a/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h +++ b/src/add-ons/kernel/file_systems/nfs4/ReplyInterpreter.h @@ -108,6 +108,8 @@ public: private: void _ParseHeader(); + static const char* _FlattenPathname(XDR::ReadStream& stream); + status_t _DecodeAttrs(XDR::ReadStream& stream, AttrValue** attrs, uint32* count); status_t _OperationError(Opcode op);