commit - f3bc9f1df29f91c63ed334a1a9c8929209f93fdc
commit + f024663dea0dea05a0d4c17d2314f38f73e85bc6
blob - /dev/null
blob + 63ad53665bec47053190034f7eb81cac0421e217 (mode 644)
--- /dev/null
+++ lib/got_lib_pkt.h
+/*
+ * Copyright (c) 2019 Ori Bernstein <ori@openbsd.org>
+ * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+const struct got_error *got_pkt_readn(ssize_t *off, int fd, void *buf,
+ size_t n);
+const struct got_error *got_pkt_flushpkt(int fd, int chattygot);
+const struct got_error *got_pkt_readhdr(int *datalen, int fd, int chattygot);
+const struct got_error *got_pkt_readpkt(int *outlen, int fd, char *buf,
+ int buflen, int chattygot);
+const struct got_error *got_pkt_writepkt(int fd, char *buf, int nbuf,
+ int chattygot);
blob - /dev/null
blob + b9ef91ba3083180edcfef203a56a0a06f4273b2b (mode 644)
--- /dev/null
+++ lib/pkt.c
+/*
+ * Copyright (c) 2019 Ori Bernstein <ori@openbsd.org>
+ * Copyright (c) 2021 Stefan Sperling <stsp@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <ctype.h>
+#include <errno.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "got_error.h"
+
+const struct got_error *
+got_pkt_readn(ssize_t *off, int fd, void *buf, size_t n)
+{
+ ssize_t r;
+
+ *off = 0;
+ while (*off != n) {
+ r = read(fd, buf + *off, n - *off);
+ if (r == -1)
+ return got_error_from_errno("read");
+ if (r == 0)
+ return NULL;
+ *off += r;
+ }
+ return NULL;
+}
+
+const struct got_error *
+got_pkt_flushpkt(int fd, int chattygot)
+{
+ ssize_t w;
+
+ if (chattygot > 1)
+ fprintf(stderr, "%s: writepkt: 0000\n", getprogname());
+
+ w = write(fd, "0000", 4);
+ if (w == -1)
+ return got_error_from_errno("write");
+ if (w != 4)
+ return got_error(GOT_ERR_IO);
+ return NULL;
+}
+
+/*
+ * Packet header contains a 4-byte hexstring which specifies the length
+ * of data which follows.
+ */
+const struct got_error *
+got_pkt_readhdr(int *datalen, int fd, int chattygot)
+{
+ static const struct got_error *err = NULL;
+ char lenstr[5];
+ long len;
+ char *e;
+ int n, i;
+ ssize_t r;
+
+ *datalen = 0;
+
+ err = got_pkt_readn(&r, fd, lenstr, 4);
+ if (err)
+ return err;
+ if (r == 0) {
+ /* implicit "0000" */
+ if (chattygot > 1)
+ fprintf(stderr, "%s: readpkt: 0000\n", getprogname());
+ return NULL;
+ }
+ if (r != 4)
+ return got_error_msg(GOT_ERR_BAD_PACKET,
+ "wrong packet header length");
+
+ lenstr[4] = '\0';
+ for (i = 0; i < 4; i++) {
+ if (!isprint((unsigned char)lenstr[i]))
+ return got_error_msg(GOT_ERR_BAD_PACKET,
+ "unprintable character in packet length field");
+ }
+ for (i = 0; i < 4; i++) {
+ if (!isxdigit((unsigned char)lenstr[i])) {
+ if (chattygot)
+ fprintf(stderr, "%s: bad length: '%s'\n",
+ getprogname(), lenstr);
+ return got_error_msg(GOT_ERR_BAD_PACKET,
+ "packet length not specified in hex");
+ }
+ }
+ errno = 0;
+ len = strtol(lenstr, &e, 16);
+ if (lenstr[0] == '\0' || *e != '\0')
+ return got_error(GOT_ERR_BAD_PACKET);
+ if (errno == ERANGE && (len == LONG_MAX || len == LONG_MIN))
+ return got_error_msg(GOT_ERR_BAD_PACKET, "bad packet length");
+ if (len > INT_MAX || len < INT_MIN)
+ return got_error_msg(GOT_ERR_BAD_PACKET, "bad packet length");
+ n = len;
+ if (n == 0)
+ return NULL;
+ if (n <= 4)
+ return got_error_msg(GOT_ERR_BAD_PACKET, "packet too short");
+ n -= 4;
+
+ *datalen = n;
+ return NULL;
+}
+
+const struct got_error *
+got_pkt_readpkt(int *outlen, int fd, char *buf, int buflen, int chattygot)
+{
+ const struct got_error *err = NULL;
+ int datalen, i;
+ ssize_t n;
+
+ err = got_pkt_readhdr(&datalen, fd, chattygot);
+ if (err)
+ return err;
+
+ if (datalen > buflen)
+ return got_error(GOT_ERR_NO_SPACE);
+
+ err = got_pkt_readn(&n, fd, buf, datalen);
+ if (err)
+ return err;
+ if (n != datalen)
+ return got_error_msg(GOT_ERR_BAD_PACKET, "short packet");
+
+ if (chattygot > 1) {
+ fprintf(stderr, "%s: readpkt: %zd:\t", getprogname(), n);
+ for (i = 0; i < n; i++) {
+ if (isprint(buf[i]))
+ fputc(buf[i], stderr);
+ else
+ fprintf(stderr, "[0x%.2x]", buf[i]);
+ }
+ fputc('\n', stderr);
+ }
+
+ *outlen = n;
+ return NULL;
+}
+
+const struct got_error *
+got_pkt_writepkt(int fd, char *buf, int nbuf, int chattygot)
+{
+ char len[5];
+ int i;
+ ssize_t w;
+
+ if (snprintf(len, sizeof(len), "%04x", nbuf + 4) >= sizeof(len))
+ return got_error(GOT_ERR_NO_SPACE);
+ w = write(fd, len, 4);
+ if (w == -1)
+ return got_error_from_errno("write");
+ if (w != 4)
+ return got_error(GOT_ERR_IO);
+ w = write(fd, buf, nbuf);
+ if (w == -1)
+ return got_error_from_errno("write");
+ if (w != nbuf)
+ return got_error(GOT_ERR_IO);
+ if (chattygot > 1) {
+ fprintf(stderr, "%s: writepkt: %s:\t", getprogname(), len);
+ for (i = 0; i < nbuf; i++) {
+ if (isprint(buf[i]))
+ fputc(buf[i], stderr);
+ else
+ fprintf(stderr, "[0x%.2x]", buf[i]);
+ }
+ fputc('\n', stderr);
+ }
+ return NULL;
+}
blob - 7823de67fa57fb34bafd9fa68b43a821a157c101
blob + 322eb5182bf517fe519edba355c7eb691286ed23
--- libexec/got-fetch-pack/Makefile
+++ libexec/got-fetch-pack/Makefile
PROG= got-fetch-pack
SRCS= got-fetch-pack.c error.c inflate.c object_parse.c \
- path.c privsep.c sha1.c
+ path.c privsep.c sha1.c pkt.c
CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
LDADD = -lutil -lz
blob - 7666d8a45ed09a018f2f8aa871943aa38616db3c
blob + 1b1a71e4dc4357b0153e9ebfa2b776af69bf006b
--- libexec/got-fetch-pack/got-fetch-pack.c
+++ libexec/got-fetch-pack/got-fetch-pack.c
#include "got_lib_object_parse.h"
#include "got_lib_privsep.h"
#include "got_lib_pack.h"
+#include "got_lib_pkt.h"
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
struct got_object *indexed;
static int chattygot;
static struct got_object_id zhash = {.sha1={0}};
-
-static const struct got_error *
-readn(ssize_t *off, int fd, void *buf, size_t n)
-{
- ssize_t r;
-
- *off = 0;
- while (*off != n) {
- r = read(fd, buf + *off, n - *off);
- if (r == -1)
- return got_error_from_errno("read");
- if (r == 0)
- return NULL;
- *off += r;
- }
- return NULL;
-}
-
-static const struct got_error *
-flushpkt(int fd)
-{
- ssize_t w;
-
- if (chattygot > 1)
- fprintf(stderr, "%s: writepkt: 0000\n", getprogname());
-
- w = write(fd, "0000", 4);
- if (w == -1)
- return got_error_from_errno("write");
- if (w != 4)
- return got_error(GOT_ERR_IO);
- return NULL;
-}
-
-/*
- * Packet header contains a 4-byte hexstring which specifies the length
- * of data which follows.
- */
-static const struct got_error *
-read_pkthdr(int *datalen, int fd)
-{
- static const struct got_error *err = NULL;
- char lenstr[5];
- long len;
- char *e;
- int n, i;
- ssize_t r;
-
- *datalen = 0;
-
- err = readn(&r, fd, lenstr, 4);
- if (err)
- return err;
- if (r == 0) {
- /* implicit "0000" */
- if (chattygot > 1)
- fprintf(stderr, "%s: readpkt: 0000\n", getprogname());
- return NULL;
- }
- if (r != 4)
- return got_error_msg(GOT_ERR_BAD_PACKET,
- "wrong packet header length");
-
- lenstr[4] = '\0';
- for (i = 0; i < 4; i++) {
- if (!isprint((unsigned char)lenstr[i]))
- return got_error_msg(GOT_ERR_BAD_PACKET,
- "unprintable character in packet length field");
- }
- for (i = 0; i < 4; i++) {
- if (!isxdigit((unsigned char)lenstr[i])) {
- if (chattygot)
- fprintf(stderr, "%s: bad length: '%s'\n",
- getprogname(), lenstr);
- return got_error_msg(GOT_ERR_BAD_PACKET,
- "packet length not specified in hex");
- }
- }
- errno = 0;
- len = strtol(lenstr, &e, 16);
- if (lenstr[0] == '\0' || *e != '\0')
- return got_error(GOT_ERR_BAD_PACKET);
- if (errno == ERANGE && (len == LONG_MAX || len == LONG_MIN))
- return got_error_msg(GOT_ERR_BAD_PACKET, "bad packet length");
- if (len > INT_MAX || len < INT_MIN)
- return got_error_msg(GOT_ERR_BAD_PACKET, "bad packet length");
- n = len;
- if (n == 0)
- return NULL;
- if (n <= 4)
- return got_error_msg(GOT_ERR_BAD_PACKET, "packet too short");
- n -= 4;
-
- *datalen = n;
- return NULL;
-}
-
-static const struct got_error *
-readpkt(int *outlen, int fd, char *buf, int buflen)
-{
- const struct got_error *err = NULL;
- int datalen, i;
- ssize_t n;
-
- err = read_pkthdr(&datalen, fd);
- if (err)
- return err;
-
- if (datalen > buflen)
- return got_error(GOT_ERR_NO_SPACE);
-
- err = readn(&n, fd, buf, datalen);
- if (err)
- return err;
- if (n != datalen)
- return got_error_msg(GOT_ERR_BAD_PACKET, "short packet");
-
- if (chattygot > 1) {
- fprintf(stderr, "%s: readpkt: %zd:\t", getprogname(), n);
- for (i = 0; i < n; i++) {
- if (isprint(buf[i]))
- fputc(buf[i], stderr);
- else
- fprintf(stderr, "[0x%.2x]", buf[i]);
- }
- fputc('\n', stderr);
- }
-
- *outlen = n;
- return NULL;
-}
-
-static const struct got_error *
-writepkt(int fd, char *buf, int nbuf)
-{
- char len[5];
- int i;
- ssize_t w;
-
- if (snprintf(len, sizeof(len), "%04x", nbuf + 4) >= sizeof(len))
- return got_error(GOT_ERR_NO_SPACE);
- w = write(fd, len, 4);
- if (w == -1)
- return got_error_from_errno("write");
- if (w != 4)
- return got_error(GOT_ERR_IO);
- w = write(fd, buf, nbuf);
- if (w == -1)
- return got_error_from_errno("write");
- if (w != nbuf)
- return got_error(GOT_ERR_IO);
- if (chattygot > 1) {
- fprintf(stderr, "%s: writepkt: %s:\t", getprogname(), len);
- for (i = 0; i < nbuf; i++) {
- if (isprint(buf[i]))
- fputc(buf[i], stderr);
- else
- fprintf(stderr, "[0x%.2x]", buf[i]);
- }
- fputc('\n', stderr);
- }
- return NULL;
-}
static void
match_remote_ref(struct got_pathlist_head *have_refs,
goto done;
}
while (1) {
- err = readpkt(&n, fd, buf, sizeof(buf));
+ err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
if (err)
goto done;
if (n == 0)
err = got_error(GOT_ERR_NO_SPACE);
goto done;
}
- err = writepkt(fd, buf, n);
+ err = got_pkt_writepkt(fd, buf, n, chattygot);
if (err)
goto done;
sent_my_capabilites = 1;
nwant++;
}
- err = flushpkt(fd);
+ err = got_pkt_flushpkt(fd, chattygot);
if (err)
goto done;
err = got_error(GOT_ERR_NO_SPACE);
goto done;
}
- err = writepkt(fd, buf, n);
+ err = got_pkt_writepkt(fd, buf, n, chattygot);
if (err)
goto done;
nhave++;
struct got_object_id common_id;
/* The server should ACK the object IDs we need. */
- err = readpkt(&n, fd, buf, sizeof(buf));
+ err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
if (err)
goto done;
if (n >= 4 && strncmp(buf, "ERR ", 4) == 0) {
}
n = snprintf(buf, sizeof(buf), "done\n");
- err = writepkt(fd, buf, n);
+ err = got_pkt_writepkt(fd, buf, n, chattygot);
if (err)
goto done;
if (nhave == 0) {
- err = readpkt(&n, fd, buf, sizeof(buf));
+ err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
if (err)
goto done;
if (n != 4 || strncmp(buf, "NAK\n", n) != 0) {
int datalen = -1;
if (have_sidebands) {
- err = read_pkthdr(&datalen, fd);
+ err = got_pkt_readhdr(&datalen, fd, chattygot);
if (err)
goto done;
if (datalen <= 0)
datalen--; /* sideband ID has been read */
if (buf[0] == GOT_SIDEBAND_PACKFILE_DATA) {
/* Read packfile data. */
- err = readn(&r, fd, buf, datalen);
+ err = got_pkt_readn(&r, fd, buf, datalen);
if (err)
goto done;
if (r != datalen) {
goto done;
}
} else if (buf[0] == GOT_SIDEBAND_PROGRESS_INFO) {
- err = readn(&r, fd, buf, datalen);
+ err = got_pkt_readn(&r, fd, buf, datalen);
if (err)
goto done;
if (r != datalen) {
goto done;
continue;
} else if (buf[0] == GOT_SIDEBAND_ERROR_INFO) {
- err = readn(&r, fd, buf, datalen);
+ err = got_pkt_readn(&r, fd, buf, datalen);
if (err)
goto done;
if (r != datalen) {
err = fetch_error(buf, r);
goto done;
} else if (buf[0] == 'A') {
- err = readn(&r, fd, buf, datalen);
+ err = got_pkt_readn(&r, fd, buf, datalen);
if (err)
goto done;
if (r != datalen) {
}
} else {
/* No sideband channel. Every byte is packfile data. */
- err = readn(&r, fd, buf, sizeof buf);
+ err = got_pkt_readn(&r, fd, buf, sizeof buf);
if (err)
goto done;
if (r <= 0)
blob - ae3ef0f8e50b2387fd389b1553182be4454aecd9
blob + ddc73e59aea2891c17b777b954fffa3a0bec90c6
--- libexec/got-send-pack/Makefile
+++ libexec/got-send-pack/Makefile
PROG= got-send-pack
SRCS= got-send-pack.c error.c inflate.c object_parse.c \
- path.c privsep.c sha1.c
+ path.c privsep.c sha1.c pkt.c
CPPFLAGS = -I${.CURDIR}/../../include -I${.CURDIR}/../../lib
LDADD = -lutil -lz
blob - 2a886f297fcabe6e08a1841e95f3913286f75c86
blob + 059def3f0aaec687446cd952534fdb52768ea4d8
--- libexec/got-send-pack/got-send-pack.c
+++ libexec/got-send-pack/got-send-pack.c
#include "got_lib_object_parse.h"
#include "got_lib_privsep.h"
#include "got_lib_pack.h"
+#include "got_lib_pkt.h"
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
struct got_object *indexed;
static int chattygot;
-
-static const struct got_error *
-readn(ssize_t *off, int fd, void *buf, size_t n)
-{
- ssize_t r;
-
- *off = 0;
- while (*off != n) {
- r = read(fd, buf + *off, n - *off);
- if (r == -1)
- return got_error_from_errno("read");
- if (r == 0)
- return NULL;
- *off += r;
- }
- return NULL;
-}
-
-static const struct got_error *
-flushpkt(int fd)
-{
- ssize_t w;
-
- if (chattygot > 1)
- fprintf(stderr, "%s: writepkt: 0000\n", getprogname());
-
- w = write(fd, "0000", 4);
- if (w == -1)
- return got_error_from_errno("write");
- if (w != 4)
- return got_error(GOT_ERR_IO);
- return NULL;
-}
-
-/*
- * Packet header contains a 4-byte hexstring which specifies the length
- * of data which follows.
- */
-static const struct got_error *
-read_pkthdr(int *datalen, int fd)
-{
- static const struct got_error *err = NULL;
- char lenstr[5];
- long len;
- char *e;
- int n, i;
- ssize_t r;
-
- *datalen = 0;
-
- err = readn(&r, fd, lenstr, 4);
- if (err)
- return err;
- if (r == 0) {
- /* implicit "0000" */
- if (chattygot > 1)
- fprintf(stderr, "%s: readpkt: 0000\n", getprogname());
- return NULL;
- }
- if (r != 4)
- return got_error_msg(GOT_ERR_BAD_PACKET,
- "wrong packet header length");
-
- lenstr[4] = '\0';
- for (i = 0; i < 4; i++) {
- if (!isprint((unsigned char)lenstr[i]))
- return got_error_msg(GOT_ERR_BAD_PACKET,
- "unprintable character in packet length field");
- }
- for (i = 0; i < 4; i++) {
- if (!isxdigit((unsigned char)lenstr[i])) {
- if (chattygot)
- fprintf(stderr, "%s: bad length: '%s'\n",
- getprogname(), lenstr);
- return got_error_msg(GOT_ERR_BAD_PACKET,
- "packet length not specified in hex");
- }
- }
- errno = 0;
- len = strtol(lenstr, &e, 16);
- if (lenstr[0] == '\0' || *e != '\0')
- return got_error(GOT_ERR_BAD_PACKET);
- if (errno == ERANGE && (len == LONG_MAX || len == LONG_MIN))
- return got_error_msg(GOT_ERR_BAD_PACKET, "bad packet length");
- if (len > INT_MAX || len < INT_MIN)
- return got_error_msg(GOT_ERR_BAD_PACKET, "bad packet length");
- n = len;
- if (n == 0)
- return NULL;
- if (n <= 4)
- return got_error_msg(GOT_ERR_BAD_PACKET, "packet too short");
- n -= 4;
- *datalen = n;
- return NULL;
-}
-
static const struct got_error *
-readpkt(int *outlen, int fd, char *buf, int buflen)
-{
- const struct got_error *err = NULL;
- int datalen, i;
- ssize_t n;
-
- err = read_pkthdr(&datalen, fd);
- if (err)
- return err;
-
- if (datalen > buflen)
- return got_error(GOT_ERR_NO_SPACE);
-
- err = readn(&n, fd, buf, datalen);
- if (err)
- return err;
- if (n != datalen)
- return got_error_msg(GOT_ERR_BAD_PACKET, "short packet");
-
- if (chattygot > 1) {
- fprintf(stderr, "%s: readpkt: %zd:\t", getprogname(), n);
- for (i = 0; i < n; i++) {
- if (isprint(buf[i]))
- fputc(buf[i], stderr);
- else
- fprintf(stderr, "[0x%.2x]", buf[i]);
- }
- fputc('\n', stderr);
- }
-
- *outlen = n;
- return NULL;
-}
-
-static const struct got_error *
-writepkt(int fd, char *buf, int nbuf)
-{
- char len[5];
- int i;
- ssize_t w;
-
- if (snprintf(len, sizeof(len), "%04x", nbuf + 4) >= sizeof(len))
- return got_error(GOT_ERR_NO_SPACE);
- w = write(fd, len, 4);
- if (w == -1)
- return got_error_from_errno("write");
- if (w != 4)
- return got_error(GOT_ERR_IO);
- w = write(fd, buf, nbuf);
- if (w == -1)
- return got_error_from_errno("write");
- if (w != nbuf)
- return got_error(GOT_ERR_IO);
- if (chattygot > 1) {
- fprintf(stderr, "%s: writepkt: %s:\t", getprogname(), len);
- for (i = 0; i < nbuf; i++) {
- if (isprint(buf[i]))
- fputc(buf[i], stderr);
- else
- fprintf(stderr, "[0x%.2x]", buf[i]);
- }
- fputc('\n', stderr);
- }
- return NULL;
-}
-
-static const struct got_error *
tokenize_refline(char **tokens, char *line, int len, int maxtokens)
{
const struct got_error *err = NULL;
return got_error(GOT_ERR_SEND_EMPTY);
while (1) {
- err = readpkt(&n, fd, buf, sizeof(buf));
+ err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
if (err)
goto done;
if (n == 0)
old_hashstr, new_hashstr);
if (err)
goto done;
- err = writepkt(fd, buf, n);
+ err = got_pkt_writepkt(fd, buf, n, chattygot);
if (err)
goto done;
if (chattygot) {
old_hashstr, new_hashstr);
if (err)
goto done;
- err = writepkt(fd, buf, n);
+ err = got_pkt_writepkt(fd, buf, n, chattygot);
if (err)
goto done;
if (chattygot) {
}
nsent++;
}
- err = flushpkt(fd);
+ err = got_pkt_flushpkt(fd, chattygot);
if (err)
goto done;
goto done;
}
- err = readpkt(&n, fd, buf, sizeof(buf));
+ err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
if (err)
goto done;
if (n >= 4 && strncmp(buf, "ERR ", 4) == 0) {
}
while (nsent > 0) {
- err = readpkt(&n, fd, buf, sizeof(buf));
+ err = got_pkt_readpkt(&n, fd, buf, sizeof(buf), chattygot);
if (err)
goto done;
if (n < 3) {