Fix infinite loop. PR#3347
authorViktor Dukhovni <openssl-users@dukhovni.org>
Sun, 11 May 2014 19:28:56 +0000 (20:28 +0100)
committerMatt Caswell <matt@openssl.org>
Sun, 11 May 2014 20:20:00 +0000 (21:20 +0100)
apps/req.c

index 9f55cdeabd4cff0c0014d6322fb5a34fc6e7e715..afabd6ca782ce83b9fe28b08acc703cbf982fd6e 100644 (file)
@@ -1574,7 +1574,13 @@ start:
 #ifdef CHARSET_EBCDIC
        ebcdic2ascii(buf, buf, i);
 #endif
-       if(!req_check_len(i, n_min, n_max)) goto start;
+       if(!req_check_len(i, n_min, n_max))
+               {
+               if (batch || value)
+                       return 0;
+               goto start;
+               }
+
        if (!X509_NAME_add_entry_by_NID(n,nid, chtype,
                                (unsigned char *) buf, -1,-1,mval)) goto err;
        ret=1;
@@ -1633,7 +1639,12 @@ start:
 #ifdef CHARSET_EBCDIC
        ebcdic2ascii(buf, buf, i);
 #endif
-       if(!req_check_len(i, n_min, n_max)) goto start;
+       if(!req_check_len(i, n_min, n_max))
+               {
+               if (batch || value)
+                       return 0;
+               goto start;
+               }
 
        if(!X509_REQ_add1_attr_by_NID(req, nid, chtype,
                                        (unsigned char *)buf, -1)) {