You've already forked pgbackrest
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:
@@ -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();
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user