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()maint
						commit
						2fb346c06a
					
				|  | @ -55,7 +55,7 @@ static int run_remote_archiver(int argc, const char **argv, | ||||||
|  |  | ||||||
| 	buf = packet_read_line(fd[0], NULL); | 	buf = packet_read_line(fd[0], NULL); | ||||||
| 	if (!buf) | 	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 (strcmp(buf, "ACK")) { | ||||||
| 		if (starts_with(buf, "NACK ")) | 		if (starts_with(buf, "NACK ")) | ||||||
| 			die(_("git archive: NACK %s"), buf + 5); | 			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); | 	char *line = packet_read_line(fd, &len); | ||||||
| 	const char *arg; | 	const char *arg; | ||||||
|  |  | ||||||
| 	if (!len) | 	if (!line) | ||||||
| 		die(_("git fetch-pack: expected ACK/NAK, got EOF")); | 		die(_("git fetch-pack: expected ACK/NAK, got a flush packet")); | ||||||
| 	if (!strcmp(line, "NAK")) | 	if (!strcmp(line, "NAK")) | ||||||
| 		return NAK; | 		return NAK; | ||||||
| 	if (skip_prefix(line, "ACK ", &arg)) { | 	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. | 		 * pkt-line matches our request. | ||||||
| 		 */ | 		 */ | ||||||
| 		line = packet_read_line_buf(&last->buf, &last->len, NULL); | 		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_reset(&exp); | ||||||
| 		strbuf_addf(&exp, "# service=%s", service); | 		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) | static int receive_unpack_status(int in) | ||||||
| { | { | ||||||
| 	const char *line = packet_read_line(in, NULL); | 	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)) | 	if (!skip_prefix(line, "unpack ", &line)) | ||||||
| 		return error(_("unable to parse remote unpack status: %s"), line); | 		return error(_("unable to parse remote unpack status: %s"), line); | ||||||
| 	if (strcmp(line, "ok")) | 	if (strcmp(line, "ok")) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	 Junio C Hamano
						Junio C Hamano