Better make sure the subtraction does not go negative before we do it.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
}
consumed = data->ofs - data->nesting->start;
- remaining = data->nesting->taglen - consumed;
- if (remaining > (data->length - data->ofs)) {
+ if (data->nesting->taglen < consumed) {
goto error;
}
- if (remaining < 0) {
+ remaining = data->nesting->taglen - consumed;
+
+ if (remaining > (data->length - data->ofs)) {
goto error;
}
return remaining;