diff options
author | Pauli <paul.dale@oracle.com> | 2017-08-24 10:46:31 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2017-08-25 06:42:17 +1000 |
commit | 678c462e213c3bf479bc93e4df5899ecfd914f91 (patch) | |
tree | debe6087b1bc4e34e59073e0430216c72d16be58 /crypto | |
parent | f7d1d2a479adaaae222d88710c6ceb85706ebb0f (diff) |
Check for EOF in ASCII conversions.
The C standard defines EOF as:
... an integer constant expression, with type int and a negative value...
This means a conforming implemenetation could define this as a one of the
printable characters. This won't be a problem for ASCII.
A specific test case has been added for EOF.
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4240)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/ctype.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/crypto/ctype.c b/crypto/ctype.c index 588c6dac3c..813be25a07 100644 --- a/crypto/ctype.c +++ b/crypto/ctype.c @@ -8,6 +8,7 @@ */ #include <string.h> +#include <stdio.h> #include "internal/ctype.h" #include "openssl/ebcdic.h" @@ -225,7 +226,7 @@ static const unsigned short ctype_char_map[128] = { #ifdef CHARSET_EBCDIC int ossl_toascii(int c) { - if (c < -128 || c > 256) + if (c < -128 || c > 256 || c == EOF) return c; /* * Adjust negatively signed characters. @@ -240,7 +241,7 @@ int ossl_toascii(int c) int ossl_fromascii(int c) { - if (c < -128 || c > 256) + if (c < -128 || c > 256 || c == EOF) return c; if (c < 0) c += 256; |