Fix allowing negative offset for snmp_pbuf_stream_seek()

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
This commit is contained in:
Harrold Spier 2020-02-21 09:38:48 +01:00 committed by Simon Goldschmidt
parent 349c077feb
commit 0192fe773e

View File

@ -135,7 +135,7 @@ snmp_pbuf_stream_writeto(struct snmp_pbuf_stream *pbuf_stream, struct snmp_pbuf_
err_t
snmp_pbuf_stream_seek(struct snmp_pbuf_stream *pbuf_stream, s32_t offset)
{
if ((offset < 0) || (offset > pbuf_stream->length)) {
if (((pbuf_stream->offset + offset) < 0) || (offset > pbuf_stream->length)) {
/* we cannot seek backwards or forward behind stream end */
return ERR_ARG;
}