From e62e3ad3d85c8988c047e787f8f64d9454e141ee Mon Sep 17 00:00:00 2001 From: Theodore Tso Date: Fri, 1 Mar 1996 00:40:43 +0000 Subject: [PATCH] Fix to work on 16-bit platforms (we don't allow greater than 64k tokens on these platforms). git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7576 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/gssapi/generic/ChangeLog | 6 ++++++ src/lib/gssapi/generic/util_token.c | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/lib/gssapi/generic/ChangeLog b/src/lib/gssapi/generic/ChangeLog index df5842944..d385e54ab 100644 --- a/src/lib/gssapi/generic/ChangeLog +++ b/src/lib/gssapi/generic/ChangeLog @@ -1,3 +1,9 @@ +Thu Feb 29 19:39:23 1996 Theodore Y. Ts'o + + * util_token.c (der_length_size, der_write_size): Fix to work on + 16-bit platforms (we don't allow greater than 64k tokens + on these platforms). + Tue Feb 27 17:49:54 1996 Theodore Y. Ts'o * gssapi.h (size_t): Make sure size_t and uid_t are defined under diff --git a/src/lib/gssapi/generic/util_token.c b/src/lib/gssapi/generic/util_token.c index d8e5e91ae..e440d907a 100644 --- a/src/lib/gssapi/generic/util_token.c +++ b/src/lib/gssapi/generic/util_token.c @@ -60,12 +60,17 @@ static int der_length_size(length) return(1); else if (length < (1<<8)) return(2); +#if (SIZEOF_INT == 2) + else + return(3); +#else else if (length < (1<<16)) return(3); else if (length < (1<<24)) return(4); else return(5); +#endif } static void der_write_length(buf, length) @@ -76,10 +81,12 @@ static void der_write_length(buf, length) *(*buf)++ = (unsigned char) length; } else { *(*buf)++ = (unsigned char) (der_length_size(length)+127); +#if (SIZEOF_INT > 2) if (length >= (1<<24)) *(*buf)++ = (unsigned char) (length>>24); if (length >= (1<<16)) *(*buf)++ = (unsigned char) ((length>>16)&0xff); +#endif if (length >= (1<<8)) *(*buf)++ = (unsigned char) ((length>>8)&0xff); *(*buf)++ = (unsigned char) (length&0xff); @@ -103,6 +110,8 @@ static int der_read_length(buf, bufsize) if (sf & 0x80) { if ((sf &= 0x7f) > ((*bufsize)-1)) return(-1); + if (sf > SIZEOF_INT) + return (-1); ret = 0; for (; sf; sf--) { ret = (ret<<8) + (*(*buf)++); -- 2.26.2