Sync with 2.2.3

This commit is contained in:
Junio C Hamano 2015-09-04 10:29:28 -07:00
commit 8267cd11d6
6 changed files with 39 additions and 26 deletions

View File

@ -0,0 +1,9 @@
Git v2.2.3 Release Notes
========================
Fixes since v2.2.2
------------------
* A handful of codepaths that used to use fixed-sized arrays to hold
pathnames have been corrected to use strbuf and other mechanisms to
allow longer pathnames without fearing overflows.

View File

@ -56,9 +56,10 @@ Documentation for older releases are available here:
link:RelNotes/2.3.1.txt[2.3.1], link:RelNotes/2.3.1.txt[2.3.1],
link:RelNotes/2.3.0.txt[2.3]. link:RelNotes/2.3.0.txt[2.3].
* link:v2.2.2/git.html[documentation for release 2.2.2] * link:v2.2.3/git.html[documentation for release 2.2.3]
* release notes for * release notes for
link:RelNotes/2.2.3.txt[2.2.3],
link:RelNotes/2.2.2.txt[2.2.2], link:RelNotes/2.2.2.txt[2.2.2],
link:RelNotes/2.2.1.txt[2.2.1], link:RelNotes/2.2.1.txt[2.2.1],
link:RelNotes/2.2.0.txt[2.2]. link:RelNotes/2.2.0.txt[2.2].

View File

@ -723,7 +723,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
if (reflog) { if (reflog) {
unsigned char sha1[20]; unsigned char sha1[20];
char nth_desc[256];
char *ref; char *ref;
int base = 0; int base = 0;
unsigned int flags = 0; unsigned int flags = 0;
@ -762,6 +761,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
for (i = 0; i < reflog; i++) { for (i = 0; i < reflog; i++) {
char *logmsg; char *logmsg;
char *nth_desc;
const char *msg; const char *msg;
unsigned long timestamp; unsigned long timestamp;
int tz; int tz;
@ -780,8 +780,10 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
show_date(timestamp, tz, 1), show_date(timestamp, tz, 1),
msg); msg);
free(logmsg); free(logmsg);
sprintf(nth_desc, "%s@{%d}", *av, base+i);
nth_desc = xstrfmt("%s@{%d}", *av, base+i);
append_ref(nth_desc, sha1, 1); append_ref(nth_desc, sha1, 1);
free(nth_desc);
} }
free(ref); free(ref);
} }

19
notes.c
View File

@ -362,13 +362,14 @@ static int non_note_cmp(const struct non_note *a, const struct non_note *b)
return strcmp(a->path, b->path); return strcmp(a->path, b->path);
} }
static void add_non_note(struct notes_tree *t, const char *path, /* note: takes ownership of path string */
static void add_non_note(struct notes_tree *t, char *path,
unsigned int mode, const unsigned char *sha1) unsigned int mode, const unsigned char *sha1)
{ {
struct non_note *p = t->prev_non_note, *n; struct non_note *p = t->prev_non_note, *n;
n = (struct non_note *) xmalloc(sizeof(struct non_note)); n = (struct non_note *) xmalloc(sizeof(struct non_note));
n->next = NULL; n->next = NULL;
n->path = xstrdup(path); n->path = path;
n->mode = mode; n->mode = mode;
hashcpy(n->sha1, sha1); hashcpy(n->sha1, sha1);
t->prev_non_note = n; t->prev_non_note = n;
@ -482,17 +483,17 @@ handle_non_note:
* component. * component.
*/ */
{ {
char non_note_path[PATH_MAX]; struct strbuf non_note_path = STRBUF_INIT;
char *p = non_note_path;
const char *q = sha1_to_hex(subtree->key_sha1); const char *q = sha1_to_hex(subtree->key_sha1);
int i; int i;
for (i = 0; i < prefix_len; i++) { for (i = 0; i < prefix_len; i++) {
*p++ = *q++; strbuf_addch(&non_note_path, *q++);
*p++ = *q++; strbuf_addch(&non_note_path, *q++);
*p++ = '/'; strbuf_addch(&non_note_path, '/');
} }
strcpy(p, entry.path); strbuf_addstr(&non_note_path, entry.path);
add_non_note(t, non_note_path, entry.mode, entry.sha1); add_non_note(t, strbuf_detach(&non_note_path, NULL),
entry.mode, entry.sha1);
} }
} }
free(buf); free(buf);

View File

@ -377,15 +377,12 @@ void read_info_alternates(const char * relative_base, int depth)
char *map; char *map;
size_t mapsz; size_t mapsz;
struct stat st; struct stat st;
const char alt_file_name[] = "info/alternates"; char *path;
/* Given that relative_base is no longer than PATH_MAX,
ensure that "path" has enough space to append "/", the
file name, "info/alternates", and a trailing NUL. */
char path[PATH_MAX + 1 + sizeof alt_file_name];
int fd; int fd;
sprintf(path, "%s/%s", relative_base, alt_file_name); path = xstrfmt("%s/info/alternates", relative_base);
fd = git_open_noatime(path); fd = git_open_noatime(path);
free(path);
if (fd < 0) if (fd < 0)
return; return;
if (fstat(fd, &st) || (st.st_size == 0)) { if (fstat(fd, &st) || (st.st_size == 0)) {

View File

@ -1434,15 +1434,18 @@ static int verify_absent_1(const struct cache_entry *ce,
if (!len) if (!len)
return 0; return 0;
else if (len > 0) { else if (len > 0) {
char path[PATH_MAX + 1]; char *path;
memcpy(path, ce->name, len); int ret;
path[len] = 0;
if (lstat(path, &st))
return error("cannot stat '%s': %s", path,
strerror(errno));
return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st, path = xmemdupz(ce->name, len);
error_type, o); if (lstat(path, &st))
ret = error("cannot stat '%s': %s", path,
strerror(errno));
else
ret = check_ok_to_remove(path, len, DT_UNKNOWN, NULL,
&st, error_type, o);
free(path);
return ret;
} else if (lstat(ce->name, &st)) { } else if (lstat(ce->name, &st)) {
if (errno != ENOENT) if (errno != ENOENT)
return error("cannot stat '%s': %s", ce->name, return error("cannot stat '%s': %s", ce->name,