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 f0b35fb4fadc8916adfbc64bb16adb79eed22f8a..5c624cbd1745c086525088f672b79107b5e1338d 100644 (file)
@@ -396,10 +396,10 @@ static int asn1_string_canon(ASN1_STRING *out, ASN1_STRING *in)
         len--;
     }
 
         len--;
     }
 
-    to = from + len - 1;
+    to = from + len;
 
     /* Ignore trailing spaces */
 
     /* Ignore trailing spaces */
-    while ((len > 0) && !(*to & 0x80) && isspace(*to)) {
+    while ((len > 0) && !(to[-1] & 0x80) && isspace(to[-1])) {
         to--;
         len--;
     }
         to--;
         len--;
     }