rewinding wrapped byte strings works, but needs more tests
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 2ad00b0..19c6a97 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -3522,8 +3522,14 @@
uError = QCBOR_ERR_INPUT_TOO_LARGE;
goto Done;
}
- const size_t uEndOfBstr = UsefulInputBuf_Tell(&(pMe->InBuf));
- const size_t uStartOfBstr = uEndOfBstr - pItem->val.string.len;
+ const size_t uStartOfBstr = UsefulInputBuf_PointerToOffset(&(pMe->InBuf), pItem->val.string.ptr);
+
+ if(uStartOfBstr == SIZE_MAX) {
+ uError = QCBOR_ERR_INPUT_TOO_LARGE;
+ goto Done;
+ }
+
+ const size_t uEndOfBstr = uStartOfBstr + pItem->val.string.len;
UsefulInputBuf_Seek(&(pMe->InBuf), uStartOfBstr);
UsefulInputBuf_SetBufferLength(&(pMe->InBuf), uEndOfBstr);