introduce RSSIZE_MAX to set maximum of ssize_t

This commit is contained in:
Lev Walkin 2017-09-15 23:32:36 -07:00
parent 1a364656a6
commit 9368263165
2 changed files with 4 additions and 1 deletions

View File

@ -145,5 +145,8 @@ typedef unsigned int uint32_t;
#ifndef RSIZE_MAX /* C11, Annex K */
#define RSIZE_MAX (SIZE_MAX >> 1)
#endif
#ifndef RSSIZE_MAX /* Halve signed size even further than unsigned */
#define RSSIZE_MAX ((ssize_t)(RSIZE_MAX >> 1))
#endif
#endif /* ASN_SYSTEM_H */

View File

@ -50,7 +50,7 @@ ber_fetch_length(int _is_constructed, const void *bufptr, size_t size,
}
if(oct == 0) {
if(len < 0 || len > RSIZE_MAX) {
if(len < 0 || len > RSSIZE_MAX) {
/* Length value out of sane range. */
return -1;
}