Skip to content

Commit 5b42477

Browse files
committed
Merge branch 'jm/maint-misc-fix' into maint
* jm/maint-misc-fix: read_gitfile_gently: use ssize_t to hold read result remove tests of always-false condition rerere.c: diagnose a corrupt MERGE_RR when hitting EOF between TAB and '\0'
2 parents a059240 + b1905ae commit 5b42477

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

fsck.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ int fsck_error_function(struct object *obj, int type, const char *fmt, ...)
349349
va_list ap;
350350
struct strbuf sb = STRBUF_INIT;
351351

352-
strbuf_addf(&sb, "object %s:", obj->sha1?sha1_to_hex(obj->sha1):"(null)");
352+
strbuf_addf(&sb, "object %s:", sha1_to_hex(obj->sha1));
353353

354354
va_start(ap, fmt);
355355
strbuf_vaddf(&sb, fmt, ap);

rerere.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,14 @@ static void read_rr(struct string_list *rr)
4747
name = xstrdup(buf);
4848
if (fgetc(in) != '\t')
4949
die("corrupt MERGE_RR");
50-
for (i = 0; i < sizeof(buf) && (buf[i] = fgetc(in)); i++)
51-
; /* do nothing */
50+
for (i = 0; i < sizeof(buf); i++) {
51+
int c = fgetc(in);
52+
if (c < 0)
53+
die("corrupt MERGE_RR");
54+
buf[i] = c;
55+
if (c == 0)
56+
break;
57+
}
5258
if (i == sizeof(buf))
5359
die("filename too long");
5460
string_list_insert(rr, buf)->util = name;

setup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const char *read_gitfile_gently(const char *path)
275275
const char *slash;
276276
struct stat st;
277277
int fd;
278-
size_t len;
278+
ssize_t len;
279279

280280
if (stat(path, &st))
281281
return NULL;

transport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static void set_upstreams(struct transport *transport, struct ref *refs,
156156
continue;
157157
if (!ref->peer_ref)
158158
continue;
159-
if (!ref->new_sha1 || is_null_sha1(ref->new_sha1))
159+
if (is_null_sha1(ref->new_sha1))
160160
continue;
161161

162162
/* Follow symbolic refs (mainly for HEAD). */

0 commit comments

Comments
 (0)