1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-11-06 08:49:29 +02:00

Replace misuse of bufSize() with bufUsed().

bufSize() should only be used whem checking the total size of the buffer, not how much of it is currently used.

In these cases bufUsed() and bufSize() are returning the same value but benign-looking code changes could break this assumption.
This commit is contained in:
David Steele
2020-10-24 13:18:02 -04:00
parent 80a770ed2e
commit ea49151746
4 changed files with 4 additions and 4 deletions

View File

@@ -392,7 +392,7 @@ cipherBlockNew(CipherMode mode, CipherType cipherType, const Buffer *pass, const
FUNCTION_LOG_END();
ASSERT(pass != NULL);
ASSERT(bufSize(pass) > 0);
ASSERT(bufUsed(pass) > 0);
// Init crypto subsystem
cryptoInit();

View File

@@ -282,7 +282,7 @@ ioReadLineParam(IoRead *this, bool allowEof)
// If the buffer is full then the linefeed (if it exists) is outside the buffer
if (bufFull(this->output))
THROW_FMT(FileReadError, "unable to find line in %zu byte buffer", bufSize(this->output));
THROW_FMT(FileReadError, "unable to find line in %zu byte buffer", bufUsed(this->output));
if (ioReadEof(this))
{

View File

@@ -451,7 +451,7 @@ xmlDocumentNewBuf(const Buffer *buffer)
FUNCTION_TEST_END();
ASSERT(buffer != NULL);
ASSERT(bufSize(buffer) > 0);
ASSERT(bufUsed(buffer) > 0);
FUNCTION_TEST_RETURN(xmlDocumentNewC(bufPtrConst(buffer), bufUsed(buffer)));
}

View File

@@ -804,7 +804,7 @@ storageS3PathRemoveInternal(StorageS3 *this, HttpRequest *request, XmlDocument *
const Buffer *response = httpResponseContent(storageS3ResponseP(request));
// Nothing is returned when there are no errors
if (bufSize(response) > 0)
if (bufUsed(response) > 0)
{
XmlNodeList *errorList = xmlNodeChildList(xmlDocumentRoot(xmlDocumentNewBuf(response)), S3_XML_TAG_ERROR_STR);