Handle last lines that aren't properly terminated.
authorRichard Levitte <levitte@openssl.org>
Thu, 14 Nov 2002 06:51:18 +0000 (06:51 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 14 Nov 2002 06:51:18 +0000 (06:51 +0000)
PR: 308

CHANGES
crypto/conf/conf_def.c

diff --git a/CHANGES b/CHANGES
index 4f64e6d..21c005c 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2082,6 +2082,10 @@ des-cbc           3624.96k     5258.21k     5530.91k     5624.30k     5628.26k
 
  Changes between 0.9.6g and 0.9.6h  [xx XXX xxxx]
 
 
  Changes between 0.9.6g and 0.9.6h  [xx XXX xxxx]
 
+  *) Change the default configuration reader to deal with last line not
+     being properly terminated.
+     [Richard Levitte]
+
   *) Change X509_NAME_cmp() so it applies the special rules on handling
      DN values that are of type PrintableString, as well as RDNs of type
      emailAddress where the value has the type ia5String.
   *) Change X509_NAME_cmp() so it applies the special rules on handling
      DN values that are of type PrintableString, as well as RDNs of type
      emailAddress where the value has the type ia5String.
index 806677d..57d2739 100644 (file)
@@ -253,9 +253,9 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
        section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
 
        bufnum=0;
        section_sk=(STACK_OF(CONF_VALUE) *)sv->value;
 
        bufnum=0;
+       again=0;
        for (;;)
                {
        for (;;)
                {
-               again=0;
                if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE))
                        {
                        CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
                if (!BUF_MEM_grow(buff,bufnum+CONFBUFSIZE))
                        {
                        CONFerr(CONF_F_CONF_LOAD_BIO,ERR_R_BUF_LIB);
@@ -266,7 +266,8 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
                BIO_gets(in, p, CONFBUFSIZE-1);
                p[CONFBUFSIZE-1]='\0';
                ii=i=strlen(p);
                BIO_gets(in, p, CONFBUFSIZE-1);
                p[CONFBUFSIZE-1]='\0';
                ii=i=strlen(p);
-               if (i == 0) break;
+               if (i == 0 && !again) break;
+               again=0;
                while (i > 0)
                        {
                        if ((p[i-1] != '\r') && (p[i-1] != '\n'))
                while (i > 0)
                        {
                        if ((p[i-1] != '\r') && (p[i-1] != '\n'))
@@ -276,7 +277,7 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
                        }
                /* we removed some trailing stuff so there is a new
                 * line on the end. */
                        }
                /* we removed some trailing stuff so there is a new
                 * line on the end. */
-               if (i == ii)
+               if (ii && i == ii)
                        again=1; /* long line */
                else
                        {
                        again=1; /* long line */
                else
                        {