aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rcynic-ng/bio_f_linebreak.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/rcynic-ng/bio_f_linebreak.c b/rcynic-ng/bio_f_linebreak.c
index f9988a3d..0376456e 100644
--- a/rcynic-ng/bio_f_linebreak.c
+++ b/rcynic-ng/bio_f_linebreak.c
@@ -120,8 +120,7 @@ static int linebreak_free(BIO *b)
static int linebreak_read(BIO *b, char *out, int outl)
{
- int ret = 0, want, n;
- char *s;
+ int ret = 0, want, n, i;
if (out == NULL || b->next_bio == NULL || outl <= 0)
return 0;
@@ -146,8 +145,11 @@ static int linebreak_read(BIO *b, char *out, int outl)
BIO_copy_next_retry(b);
if (n > 0) {
- if ((s = memrchr(out, '\n', n)) != NULL)
- b->num = (out + n) - (s + 1);
+ for (i = n - 1; i >= 0; i--)
+ if (out[i] == '\n')
+ break;
+ if (i >= 0)
+ b->num = n - i - 1;
else
b->num += n;
out += n;