[openssl-commits] [openssl] master update
paul.dale at oracle.com
paul.dale at oracle.com
Thu Aug 24 20:42:28 UTC 2017
The branch master has been updated
via 678c462e213c3bf479bc93e4df5899ecfd914f91 (commit)
from f7d1d2a479adaaae222d88710c6ceb85706ebb0f (commit)
- Log -----------------------------------------------------------------
commit 678c462e213c3bf479bc93e4df5899ecfd914f91
Author: Pauli <paul.dale at oracle.com>
Date: Thu Aug 24 10:46:31 2017 +1000
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 at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4240)
-----------------------------------------------------------------------
Summary of changes:
crypto/ctype.c | 5 +++--
test/ctype_internal_test.c | 6 ++++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/crypto/ctype.c b/crypto/ctype.c
index 588c6da..813be25 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;
diff --git a/test/ctype_internal_test.c b/test/ctype_internal_test.c
index 6b66cfb..04ab14d 100644
--- a/test/ctype_internal_test.c
+++ b/test/ctype_internal_test.c
@@ -68,10 +68,16 @@ static int test_ctype_tolower(int n)
&& TEST_int_eq(ossl_tolower(case_change[n].l), case_change[n].l);
}
+static int test_ctype_eof(void)
+{
+ return test_ctype_chars(EOF);
+}
+
int setup_tests(void)
{
ADD_ALL_TESTS(test_ctype_chars, 128);
ADD_ALL_TESTS(test_ctype_toupper, OSSL_NELEM(case_change));
ADD_ALL_TESTS(test_ctype_tolower, OSSL_NELEM(case_change));
+ ADD_TEST(test_ctype_eof);
return 1;
}
More information about the openssl-commits
mailing list