Update to libfetch-2.17. Fix a bug in the line buffering code to not
drop output if the server actually send more than one line.
This commit is contained in:
parent
85f76ee71a
commit
f298aa9202
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: common.c,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: common.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
|
||||
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
|
||||
|
@ -234,6 +234,8 @@ fetch_reopen(int sd)
|
|||
/* allocate and fill connection structure */
|
||||
if ((conn = calloc(1, sizeof(*conn))) == NULL)
|
||||
return (NULL);
|
||||
conn->next_buf = NULL;
|
||||
conn->next_len = 0;
|
||||
conn->sd = sd;
|
||||
++conn->ref;
|
||||
return (conn);
|
||||
|
@ -405,6 +407,15 @@ fetch_read(conn_t *conn, char *buf, size_t len)
|
|||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
if (conn->next_len != 0) {
|
||||
if (conn->next_len < len)
|
||||
len = conn->next_len;
|
||||
memmove(buf, conn->next_buf, len);
|
||||
conn->next_len -= len;
|
||||
conn->next_buf += len;
|
||||
return len;
|
||||
}
|
||||
|
||||
if (fetchTimeout) {
|
||||
FD_ZERO(&readfds);
|
||||
gettimeofday(&timeout, NULL);
|
||||
|
@ -459,13 +470,12 @@ fetch_read(conn_t *conn, char *buf, size_t len)
|
|||
int
|
||||
fetch_getln(conn_t *conn)
|
||||
{
|
||||
char *tmp;
|
||||
char *tmp, *next;
|
||||
size_t tmpsize;
|
||||
ssize_t len;
|
||||
int done;
|
||||
|
||||
if (conn->buf == NULL) {
|
||||
if ((conn->buf = malloc(MIN_BUF_SIZE)) == NULL) {
|
||||
if ((conn->buf = malloc(MIN_BUF_SIZE + 1)) == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (-1);
|
||||
}
|
||||
|
@ -474,6 +484,7 @@ fetch_getln(conn_t *conn)
|
|||
|
||||
conn->buf[0] = '\0';
|
||||
conn->buflen = 0;
|
||||
next = NULL;
|
||||
|
||||
do {
|
||||
len = fetch_read(conn, conn->buf + conn->buflen,
|
||||
|
@ -482,9 +493,10 @@ fetch_getln(conn_t *conn)
|
|||
return (-1);
|
||||
if (len == 0)
|
||||
break;
|
||||
done = memchr(conn->buf + conn->buflen, '\n', len) != NULL;
|
||||
next = memchr(conn->buf + conn->buflen, '\n', len);
|
||||
conn->buflen += len;
|
||||
if (conn->buflen == conn->bufsize) {
|
||||
if (conn->buflen == conn->bufsize &&
|
||||
(next == NULL || next[1] == '\0')) {
|
||||
tmp = conn->buf;
|
||||
tmpsize = conn->bufsize * 2 + 1;
|
||||
if ((tmp = realloc(tmp, tmpsize)) == NULL) {
|
||||
|
@ -494,8 +506,13 @@ fetch_getln(conn_t *conn)
|
|||
conn->buf = tmp;
|
||||
conn->bufsize = tmpsize;
|
||||
}
|
||||
} while (!done);
|
||||
} while (next == NULL);
|
||||
|
||||
if (next != NULL) {
|
||||
conn->next_buf = next + 1;
|
||||
conn->next_len = conn->buflen - (conn->next_buf - conn->buf);
|
||||
conn->buflen = next - conn->buf;
|
||||
}
|
||||
conn->buf[conn->buflen] = '\0';
|
||||
return (0);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: common.h,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: common.h,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
|
||||
* All rights reserved.
|
||||
|
@ -57,6 +57,8 @@ struct fetchconn {
|
|||
char *buf; /* buffer */
|
||||
size_t bufsize; /* buffer size */
|
||||
size_t buflen; /* length of buffer contents */
|
||||
char *next_buf; /* pending buffer, e.g. after getln */
|
||||
size_t next_len; /* size of pending buffer */
|
||||
int err; /* last protocol reply code */
|
||||
#ifdef WITH_SSL
|
||||
SSL *ssl; /* SSL handle */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/sh
|
||||
# $NetBSD: errlist.sh,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $
|
||||
# $NetBSD: errlist.sh,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
|
||||
|
||||
printf "static struct fetcherr $1[] = {\n"
|
||||
while read code type msg; do
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
.\" SUCH DAMAGE.
|
||||
.\"
|
||||
.\" $FreeBSD: fetch.3,v 1.64 2007/12/18 11:03:26 des Exp $
|
||||
.\" $NetBSD: fetch.3,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $
|
||||
.\" $NetBSD: fetch.3,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
|
||||
.\"
|
||||
.Dd April 25, 2008
|
||||
.Dt FETCH 3
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fetch.c,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: fetch.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
|
||||
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fetch.h,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: fetch.h,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
|
||||
* All rights reserved.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: file.c,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: file.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
|
||||
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ftp.c,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: ftp.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 1998-2004 Dag-Erling Coïdan Smørgrav
|
||||
* Copyright (c) 2008 Joerg Sonnenberger <joerg@NetBSD.org>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: ftp.errors,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $
|
||||
# $NetBSD: ftp.errors,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
|
||||
# $FreeBSD: ftp.errors,v 1.6 2002/10/30 06:06:16 des Exp $
|
||||
#
|
||||
# This list is taken from RFC 959.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: http.c,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $ */
|
||||
/* $NetBSD: http.c,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $ */
|
||||
/*-
|
||||
* Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
|
||||
* Copyright (c) 2003 Thomas Klausner <wiz@NetBSD.org>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# $FreeBSD: http.errors,v 1.5 2001/05/23 18:52:02 des Exp $
|
||||
# $NetBSD: http.errors,v 1.1.1.1 2008/09/30 18:46:07 joerg Exp $
|
||||
# $NetBSD: http.errors,v 1.1.1.2 2008/10/07 15:55:20 joerg Exp $
|
||||
#
|
||||
# This list is taken from RFC 2068.
|
||||
#
|
||||
|
|
Loading…
Reference in New Issue