Skip to content

Commit

Permalink
[XrdPosix] Use strncpy when copying checksum.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonmichal committed Jun 23, 2017
1 parent 0caef52 commit f07c8b7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/XrdPosix/XrdPosixAdmin.cc
Expand Up @@ -105,10 +105,14 @@ int XrdPosixAdmin::Query(XrdCl::QueryCode::Code reqCode, void *buff, int bsz)
//
if (!XrdPosixMap::Result(Xrd.Query(reqCode, reqBuff, rspBuff)))
{uint32_t rspSz = rspBuff->GetSize();
if (bsz >= (int)rspSz)
{strcpy((char *)buff, rspBuff->GetBuffer());
// if the string is null-terminated decrement the size
char *rspbuff = rspBuff->GetBuffer();
if ( !(rspbuff[rspSz - 1]) ) --rspSz;
if (bsz >= (int)rspSz + 1)
{strncpy((char *)buff, rspbuff, rspSz);
((char*)buff)[rspSz] = 0; // make sure the string is null-terminated
delete rspBuff;
return static_cast<int>(rspSz);
return static_cast<int>(rspSz + 1);
}
errno = ERANGE;
}
Expand Down

0 comments on commit f07c8b7

Please sign in to comment.