Make sure to NUL-terminate the string on end-of-file (and error)

PR: 643
This commit is contained in:
Richard Levitte
2003-06-11 18:43:47 +00:00
parent 0a02757b03
commit c2edb62beb

View File

@@ -169,6 +169,7 @@ start:
if (i <= 0)
{
BIO_copy_next_retry(b);
*buf='\0';
if (i < 0) return((num > 0)?num:i);
if (i == 0) return(num);
}
@@ -495,6 +496,9 @@ static int buffer_gets(BIO *b, char *buf, int size)
if (i <= 0)
{
BIO_copy_next_retry(b);
*buf='\0';
fprintf(stderr, "DEBUG[buffer_gets]: i = %d\n",
i);
if (i < 0) return((num > 0)?num:i);
if (i == 0) return(num);
}