summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/asn1/x_long.c
diff options
context:
space:
mode:
authormarkus <>2004-04-07 20:42:07 +0000
committermarkus <>2004-04-07 20:42:07 +0000
commit58c08aa241f168c84ce7cc3052454ea59a44eada (patch)
tree1806747a3fda66041a998ca63c763fdcf722450e /src/lib/libcrypto/asn1/x_long.c
parent9c1aa44a1eacea897c0432e796b205b8484ff4d2 (diff)
downloadopenbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.tar.gz
openbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.tar.bz2
openbsd-58c08aa241f168c84ce7cc3052454ea59a44eada.zip
import openssl-0.9.7d
Diffstat (limited to 'src/lib/libcrypto/asn1/x_long.c')
-rw-r--r--src/lib/libcrypto/asn1/x_long.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/libcrypto/asn1/x_long.c b/src/lib/libcrypto/asn1/x_long.c
index c04b192794..c5f25956cb 100644
--- a/src/lib/libcrypto/asn1/x_long.c
+++ b/src/lib/libcrypto/asn1/x_long.c
@@ -104,7 +104,12 @@ static int long_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype, const A
104 long ltmp; 104 long ltmp;
105 unsigned long utmp; 105 unsigned long utmp;
106 int clen, pad, i; 106 int clen, pad, i;
107 ltmp = *(long *)pval; 107 /* this exists to bypass broken gcc optimization */
108 char *cp = (char *)pval;
109
110 /* use memcpy, because we may not be long aligned */
111 memcpy(&ltmp, cp, sizeof(long));
112
108 if(ltmp == it->size) return -1; 113 if(ltmp == it->size) return -1;
109 /* Convert the long to positive: we subtract one if negative so 114 /* Convert the long to positive: we subtract one if negative so
110 * we can cleanly handle the padding if only the MSB of the leading 115 * we can cleanly handle the padding if only the MSB of the leading
@@ -136,6 +141,7 @@ static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype,
136 int neg, i; 141 int neg, i;
137 long ltmp; 142 long ltmp;
138 unsigned long utmp = 0; 143 unsigned long utmp = 0;
144 char *cp = (char *)pval;
139 if(len > sizeof(long)) { 145 if(len > sizeof(long)) {
140 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); 146 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
141 return 0; 147 return 0;
@@ -158,6 +164,6 @@ static int long_c2i(ASN1_VALUE **pval, unsigned char *cont, int len, int utype,
158 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG); 164 ASN1err(ASN1_F_LONG_C2I, ASN1_R_INTEGER_TOO_LARGE_FOR_LONG);
159 return 0; 165 return 0;
160 } 166 }
161 *(long *)pval = ltmp; 167 memcpy(cp, &ltmp, sizeof(long));
162 return 1; 168 return 1;
163} 169}