diff options
author | Andy Polyakov <appro@openssl.org> | 2017-11-11 22:14:43 +0100 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2017-11-13 11:03:00 +0100 |
commit | a6f4e3fe622764667cc733c0bc1b498032827f44 (patch) | |
tree | 019701c4fe2592b6c3dda3699f45f6b1ce6b42be /crypto | |
parent | b571802dfaa265082c27f690ead0b4e4b8e2b14c (diff) |
asn1/a_strex.c: fix flags truncation in do_esc_char.
|flags| argument to do_esc_char was apparently truncated by implicit
cast. [Caught by VC warning subsytem.]
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4721)
(cherry picked from commit 372463103917fcc2b68bd2ba3db55b29ce325705)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/asn1/a_strex.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/crypto/asn1/a_strex.c b/crypto/asn1/a_strex.c index 1bc06799af..933dda99b7 100644 --- a/crypto/asn1/a_strex.c +++ b/crypto/asn1/a_strex.c @@ -63,7 +63,7 @@ typedef int char_io (void *arg, const void *buf, int len); * even 4 byte forms. */ -static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, +static int do_esc_char(unsigned long c, unsigned short flags, char *do_quotes, char_io *io_ch, void *arg) { unsigned short chflgs; @@ -116,7 +116,7 @@ static int do_esc_char(unsigned long c, unsigned char flags, char *do_quotes, * If we get this far and do any escaping at all must escape the escape * character itself: backslash. */ - if (chtmp == '\\' && flags & ESC_FLAGS) { + if (chtmp == '\\' && (flags & ESC_FLAGS)) { if (!io_ch(arg, "\\\\", 2)) return -1; return 2; @@ -143,6 +143,7 @@ static int do_buf(unsigned char *buf, int buflen, unsigned short orflags; unsigned char *p, *q; unsigned long c; + p = buf; q = buf + buflen; outlen = 0; @@ -190,17 +191,15 @@ static int do_buf(unsigned char *buf, int buflen, * otherwise each character will be > 0x7f and so the * character will never be escaped on first and last. */ - len = - do_esc_char(utfbuf[i], (unsigned short)(flags | orflags), - quotes, io_ch, arg); + len = do_esc_char(utfbuf[i], flags | orflags, quotes, + io_ch, arg); if (len < 0) return -1; outlen += len; } } else { - len = - do_esc_char(c, (unsigned short)(flags | orflags), quotes, - io_ch, arg); + len = do_esc_char(c, flags | orflags, quotes, + io_ch, arg); if (len < 0) return -1; outlen += len; |