[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
Sun Sep 8 12:08:50 CEST 2019




Nikos Mavrogiannopoulos started a new discussion on lib/gnutls_int.h: https://gitlab.com/gnutls/gnutls/merge_requests/1056#note_213866862

>  
>  #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)

All look fine to me, but should we re-use these macros to ensure that the same checks are applied universally? (now all are applied, but a future MR could miss updating one macro)

-- 
Reply to this email directly or view it on GitLab: https://gitlab.com/gnutls/gnutls/merge_requests/1056#note_213866862
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/20190908/4efeb9ee/attachment.html>


More information about the Gnutls-devel mailing list