From 7c958f8f9ca529ed9873fc93ecfe5d03576d07c7 Mon Sep 17 00:00:00 2001 From: "wtc%google.com" Date: Thu, 13 Jan 2011 00:26:57 +0000 Subject: [PATCH] Bug 572289: SEC_ASN1EncodeInteger cannot correctly encode some positive integer values. r=nelson. Tag: NSS_3_12_BRANCH git-svn-id: svn://10.0.0.236/branches/NSS_3_12_BRANCH@261743 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/security/nss/lib/util/secasn1e.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mozilla/security/nss/lib/util/secasn1e.c b/mozilla/security/nss/lib/util/secasn1e.c index e21fc4cfe94..14688074984 100644 --- a/mozilla/security/nss/lib/util/secasn1e.c +++ b/mozilla/security/nss/lib/util/secasn1e.c @@ -38,7 +38,7 @@ * Support for ENcoding ASN.1 data based on BER/DER (Basic/Distinguished * Encoding Rules). * - * $Id: secasn1e.c,v 1.21 2006-04-07 11:41:18 kaie%kuix.de Exp $ + * $Id: secasn1e.c,v 1.21.66.1 2011-01-13 00:26:57 wtc%google.com Exp $ */ #include "secasn1.h" @@ -1587,7 +1587,7 @@ SEC_ASN1EncodeItem (PRArenaPool *poolp, SECItem *dest, const void *src, static SECItem * sec_asn1e_integer(PRArenaPool *poolp, SECItem *dest, unsigned long value, - PRBool make_unsigned) + PRBool is_unsigned) { unsigned long copy; unsigned char sign; @@ -1604,11 +1604,11 @@ sec_asn1e_integer(PRArenaPool *poolp, SECItem *dest, unsigned long value, } while (copy); /* - * If this is an unsigned encoding, and the high bit of the last + * If 'value' is non-negative, and the high bit of the last * byte we counted was set, we need to add one to the length so * we put a high-order zero byte in the encoding. */ - if (sign && make_unsigned) + if (sign && (is_unsigned || (long)value >= 0)) len++; /*