diff --git a/src/util-buffer.c b/src/util-buffer.c index 5b52a05dc4..05b3658258 100644 --- a/src/util-buffer.c +++ b/src/util-buffer.c @@ -109,7 +109,7 @@ void MemBufferPrintToFPAsHex(MemBuffer *b, FILE *fp) } } -void MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len) +uint32_t MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len) { uint32_t write_len; if (raw_len >= dst->size - dst->offset) { @@ -121,6 +121,7 @@ void MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_le memcpy(dst->buffer + dst->offset, raw, write_len); dst->offset += write_len; dst->buffer[dst->offset] = '\0'; + return write_len; } void MemBufferWriteString(MemBuffer *dst, const char *fmt, ...) diff --git a/src/util-buffer.h b/src/util-buffer.h index b1fcb62f2b..fa756655bd 100644 --- a/src/util-buffer.h +++ b/src/util-buffer.h @@ -111,8 +111,9 @@ void MemBufferPrintToFPAsHex(MemBuffer *b, FILE *fp); * * \param raw_buffer The buffer to write. * \param raw_buffer_len Length of the above buffer. + * \retval write_len Bytes written. If less than raw_len, the buffer is full. */ -void MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len); +uint32_t MemBufferWriteRaw(MemBuffer *dst, const uint8_t *raw, const uint32_t raw_len); /** * \brief Write a string buffer to the Membuffer dst.