[gnutls-devel] GnuTLS | gnutls_int.h: make DECR_LEN neutral to signedness (!1056)
Development of GNU's TLS library
gnutls-devel at lists.gnutls.org
Wed Sep 11 15:51:07 CEST 2019
Nikos Mavrogiannopoulos commented on a discussion on lib/gnutls_int.h: https://gitlab.com/gnutls/gnutls/merge_requests/1056#note_215623057
>
> #define MEMSUB(x,y) ((ssize_t)((ptrdiff_t)x-(ptrdiff_t)y))
>
> -#define DECR_LEN(len, x) do { len-=x; if (len<0) {gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} } while (0)
> +#define DECR_LEN(len, x) do { if (len<x) {gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH;} else len-=x; } while (0)
I was thinking that as these macros become more complex, it would be easy to introduce a change in one of them and miss updating the other.
To address that, what do you think of wrapping the macros over each other? Eg:
```
#define DECR_LEN(len, x) DECR_LENGTH_RET(len, x, GNUTLS_E_UNEXPECTED_PACKET_LENGTH)
#define DECR_LEN_RET(len, x, rval) DECR_LENGTH_COM(len, x, return rval)
```
That is to have a single place to update/fix.
--
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/merge_requests/1056#note_215623057
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gnupg.org/pipermail/gnutls-devel/attachments/20190911/4fdd82c8/attachment.html>
More information about the Gnutls-devel
mailing list