Merge branch 'js/packet-read-line-check-null'
Some low level protocol codepath could crash when they get an unexpected flush packet, which is now fixed. * js/packet-read-line-check-null: always check for NULL return from packet_read_line() correct error messages for NULL packet_read_line()
This commit is contained in:
commit
2fb346c06a
@ -55,7 +55,7 @@ static int run_remote_archiver(int argc, const char **argv,
|
||||
|
||||
buf = packet_read_line(fd[0], NULL);
|
||||
if (!buf)
|
||||
die(_("git archive: expected ACK/NAK, got EOF"));
|
||||
die(_("git archive: expected ACK/NAK, got a flush packet"));
|
||||
if (strcmp(buf, "ACK")) {
|
||||
if (starts_with(buf, "NACK "))
|
||||
die(_("git archive: NACK %s"), buf + 5);
|
||||
|
@ -261,8 +261,8 @@ static enum ack_type get_ack(int fd, struct object_id *result_oid)
|
||||
char *line = packet_read_line(fd, &len);
|
||||
const char *arg;
|
||||
|
||||
if (!len)
|
||||
die(_("git fetch-pack: expected ACK/NAK, got EOF"));
|
||||
if (!line)
|
||||
die(_("git fetch-pack: expected ACK/NAK, got a flush packet"));
|
||||
if (!strcmp(line, "NAK"))
|
||||
return NAK;
|
||||
if (skip_prefix(line, "ACK ", &arg)) {
|
||||
|
@ -351,6 +351,8 @@ static struct discovery *discover_refs(const char *service, int for_push)
|
||||
* pkt-line matches our request.
|
||||
*/
|
||||
line = packet_read_line_buf(&last->buf, &last->len, NULL);
|
||||
if (!line)
|
||||
die("invalid server response; expected service, got flush packet");
|
||||
|
||||
strbuf_reset(&exp);
|
||||
strbuf_addf(&exp, "# service=%s", service);
|
||||
|
@ -137,6 +137,8 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc
|
||||
static int receive_unpack_status(int in)
|
||||
{
|
||||
const char *line = packet_read_line(in, NULL);
|
||||
if (!line)
|
||||
return error(_("unexpected flush packet while reading remote unpack status"));
|
||||
if (!skip_prefix(line, "unpack ", &line))
|
||||
return error(_("unable to parse remote unpack status: %s"), line);
|
||||
if (strcmp(line, "ok"))
|
||||
|
Loading…
Reference in New Issue
Block a user