Avoid creating an illegal pointer
authorKurt Roeckx <kurt@roeckx.be>
Sat, 4 Jun 2016 14:25:39 +0000 (16:25 +0200)
committerKurt Roeckx <kurt@roeckx.be>
Sat, 11 Jun 2016 14:43:48 +0000 (16:43 +0200)
Found by tis-interpreter

Reviewed-by: Rich Salz <rsalz@openssl.org>
GH: #1164

crypto/x509/x_name.c

index f0b35fb..5c624cb 100644 (file)
@@ -396,10 +396,10 @@ static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in)
         len--;
     }
 
-    to = from + len - 1;
+    to = from + len;
 
     /* Ignore trailing spaces */
-    while ((len > 0) && !(*to & 0x80) && isspace(*to)) {
+    while ((len > 0) && !(to[-1] & 0x80) && isspace(to[-1])) {
         to--;
         len--;
     }