Skip to content

Commit bc9d4dc

Browse files
peffgitster
authored andcommitted
correct error messages for NULL packet_read_line()
The packet_read_line() function dies if it gets an unexpected EOF. It only returns NULL if we get a flush packet (or technically, a zero-length "0004" packet, but nobody is supposed to send those, and they are indistinguishable from a flush in this interface). Let's correct error messages which claim an unexpected EOF; it's really an unexpected flush packet. While we're here, let's also check "!line" instead of "!len" in the second case. The two events should always coincide, but checking "!line" makes it more obvious that we are not about to dereference NULL. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 8279ed0 commit bc9d4dc

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin/archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static int run_remote_archiver(int argc, const char **argv,
5555

5656
buf = packet_read_line(fd[0], NULL);
5757
if (!buf)
58-
die(_("git archive: expected ACK/NAK, got EOF"));
58+
die(_("git archive: expected ACK/NAK, got a flush packet"));
5959
if (strcmp(buf, "ACK")) {
6060
if (starts_with(buf, "NACK "))
6161
die(_("git archive: NACK %s"), buf + 5);

fetch-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,8 @@ static enum ack_type get_ack(int fd, struct object_id *result_oid)
260260
char *line = packet_read_line(fd, &len);
261261
const char *arg;
262262

263-
if (!len)
264-
die(_("git fetch-pack: expected ACK/NAK, got EOF"));
263+
if (!line)
264+
die(_("git fetch-pack: expected ACK/NAK, got a flush packet"));
265265
if (!strcmp(line, "NAK"))
266266
return NAK;
267267
if (skip_prefix(line, "ACK ", &arg)) {

0 commit comments

Comments
 (0)