db2b3d263a
- Fix remote code execution via buffer overflow (CVE-2016-2315, CVE-2016-2324, bsc#971328): 0012-http-push-stop-using-name_path.patch 0013-show_object_with_name-simplify-by-using-path_name.patch 0014-list-objects-convert-name_path-to-a-strbuf.patch 0015-list-objects-drop-name_path-entirely.patch 0016-list-objects-pass-full-pathname-to-callbacks.patch OBS-URL: https://build.opensuse.org/request/show/373839 OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/cgit?expand=0&rev=27
236 lines
7.7 KiB
Diff
236 lines
7.7 KiB
Diff
From bd64516aca4d4e22acb33c71429d293a14d355cf Mon Sep 17 00:00:00 2001
|
|
From: Jeff King <peff@peff.net>
|
|
Date: Thu, 11 Feb 2016 17:26:44 -0500
|
|
Subject: [PATCH 5/6] list-objects: drop name_path entirely
|
|
|
|
In the previous commit, we left name_path as a thin wrapper
|
|
around a strbuf. This patch drops it entirely. As a result,
|
|
every show_object_fn callback needs to be adjusted. However,
|
|
none of their code needs to be changed at all, because the
|
|
only use was to pass it to path_name(), which now handles
|
|
the bare strbuf.
|
|
|
|
Signed-off-by: Jeff King <peff@peff.net>
|
|
Signed-off-by: Junio C Hamano <gitster@pobox.com>
|
|
---
|
|
builtin/pack-objects.c | 4 ++--
|
|
builtin/rev-list.c | 4 ++--
|
|
list-objects.c | 12 +++++-------
|
|
list-objects.h | 2 +-
|
|
pack-bitmap-write.c | 2 +-
|
|
pack-bitmap.c | 4 ++--
|
|
reachable.c | 2 +-
|
|
revision.c | 6 +++---
|
|
revision.h | 8 ++------
|
|
9 files changed, 19 insertions(+), 25 deletions(-)
|
|
|
|
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
|
|
index 4dae5b11c28d..8bbb9bd9aa9b 100644
|
|
--- a/builtin/pack-objects.c
|
|
+++ b/builtin/pack-objects.c
|
|
@@ -2285,7 +2285,7 @@ static void show_commit(struct commit *commit, void *data)
|
|
}
|
|
|
|
static void show_object(struct object *obj,
|
|
- const struct name_path *path, const char *last,
|
|
+ struct strbuf *path, const char *last,
|
|
void *data)
|
|
{
|
|
char *name = path_name(path, last);
|
|
@@ -2480,7 +2480,7 @@ static int get_object_list_from_bitmap(struct rev_info *revs)
|
|
}
|
|
|
|
static void record_recent_object(struct object *obj,
|
|
- const struct name_path *path,
|
|
+ struct strbuf *path,
|
|
const char *last,
|
|
void *data)
|
|
{
|
|
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
|
|
index 3aa89a1a3cd9..a92c3ca852c9 100644
|
|
--- a/builtin/rev-list.c
|
|
+++ b/builtin/rev-list.c
|
|
@@ -178,7 +178,7 @@ static void finish_commit(struct commit *commit, void *data)
|
|
}
|
|
|
|
static void finish_object(struct object *obj,
|
|
- const struct name_path *path, const char *name,
|
|
+ struct strbuf *path, const char *name,
|
|
void *cb_data)
|
|
{
|
|
struct rev_list_info *info = cb_data;
|
|
@@ -189,7 +189,7 @@ static void finish_object(struct object *obj,
|
|
}
|
|
|
|
static void show_object(struct object *obj,
|
|
- const struct name_path *path, const char *component,
|
|
+ struct strbuf *path, const char *component,
|
|
void *cb_data)
|
|
{
|
|
struct rev_list_info *info = cb_data;
|
|
diff --git a/list-objects.c b/list-objects.c
|
|
index 4f60a3ea2aa5..43977665d30f 100644
|
|
--- a/list-objects.c
|
|
+++ b/list-objects.c
|
|
@@ -11,7 +11,7 @@
|
|
static void process_blob(struct rev_info *revs,
|
|
struct blob *blob,
|
|
show_object_fn show,
|
|
- struct name_path *path,
|
|
+ struct strbuf *path,
|
|
const char *name,
|
|
void *cb_data)
|
|
{
|
|
@@ -52,7 +52,7 @@ static void process_blob(struct rev_info *revs,
|
|
static void process_gitlink(struct rev_info *revs,
|
|
const unsigned char *sha1,
|
|
show_object_fn show,
|
|
- struct name_path *path,
|
|
+ struct strbuf *path,
|
|
const char *name,
|
|
void *cb_data)
|
|
{
|
|
@@ -69,7 +69,6 @@ static void process_tree(struct rev_info *revs,
|
|
struct object *obj = &tree->object;
|
|
struct tree_desc desc;
|
|
struct name_entry entry;
|
|
- struct name_path me;
|
|
enum interesting match = revs->diffopt.pathspec.nr == 0 ?
|
|
all_entries_interesting: entry_not_interesting;
|
|
int baselen = base->len;
|
|
@@ -87,8 +86,7 @@ static void process_tree(struct rev_info *revs,
|
|
}
|
|
|
|
obj->flags |= SEEN;
|
|
- me.base = base;
|
|
- show(obj, &me, name, cb_data);
|
|
+ show(obj, base, name, cb_data);
|
|
|
|
strbuf_addstr(base, name);
|
|
if (base->len)
|
|
@@ -113,12 +111,12 @@ static void process_tree(struct rev_info *revs,
|
|
cb_data);
|
|
else if (S_ISGITLINK(entry.mode))
|
|
process_gitlink(revs, entry.sha1,
|
|
- show, &me, entry.path,
|
|
+ show, base, entry.path,
|
|
cb_data);
|
|
else
|
|
process_blob(revs,
|
|
lookup_blob(entry.sha1),
|
|
- show, &me, entry.path,
|
|
+ show, base, entry.path,
|
|
cb_data);
|
|
}
|
|
strbuf_setlen(base, baselen);
|
|
diff --git a/list-objects.h b/list-objects.h
|
|
index 136a1da5a6f0..69c4c7de6efe 100644
|
|
--- a/list-objects.h
|
|
+++ b/list-objects.h
|
|
@@ -2,7 +2,7 @@
|
|
#define LIST_OBJECTS_H
|
|
|
|
typedef void (*show_commit_fn)(struct commit *, void *);
|
|
-typedef void (*show_object_fn)(struct object *, const struct name_path *, const char *, void *);
|
|
+typedef void (*show_object_fn)(struct object *, struct strbuf *, const char *, void *);
|
|
void traverse_commit_list(struct rev_info *, show_commit_fn, show_object_fn, void *);
|
|
|
|
typedef void (*show_edge_fn)(struct commit *);
|
|
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
|
|
index 6bff970c905b..65ed3425b33f 100644
|
|
--- a/pack-bitmap-write.c
|
|
+++ b/pack-bitmap-write.c
|
|
@@ -148,7 +148,7 @@ static uint32_t find_object_pos(const unsigned char *sha1)
|
|
return entry->in_pack_pos;
|
|
}
|
|
|
|
-static void show_object(struct object *object, const struct name_path *path,
|
|
+static void show_object(struct object *object, struct strbuf *path,
|
|
const char *last, void *data)
|
|
{
|
|
struct bitmap *base = data;
|
|
diff --git a/pack-bitmap.c b/pack-bitmap.c
|
|
index dd8dc16e676f..51f790e7ce10 100644
|
|
--- a/pack-bitmap.c
|
|
+++ b/pack-bitmap.c
|
|
@@ -414,7 +414,7 @@ static int ext_index_add_object(struct object *object, const char *name)
|
|
return bitmap_pos + bitmap_git.pack->num_objects;
|
|
}
|
|
|
|
-static void show_object(struct object *object, const struct name_path *path,
|
|
+static void show_object(struct object *object, struct strbuf *path,
|
|
const char *last, void *data)
|
|
{
|
|
struct bitmap *base = data;
|
|
@@ -895,7 +895,7 @@ struct bitmap_test_data {
|
|
};
|
|
|
|
static void test_show_object(struct object *object,
|
|
- const struct name_path *path,
|
|
+ struct strbuf *path,
|
|
const char *last, void *data)
|
|
{
|
|
struct bitmap_test_data *tdata = data;
|
|
diff --git a/reachable.c b/reachable.c
|
|
index 43616d49c7f8..e60f08d2f041 100644
|
|
--- a/reachable.c
|
|
+++ b/reachable.c
|
|
@@ -43,7 +43,7 @@ static int add_one_ref(const char *path, const struct object_id *oid,
|
|
* The traversal will have already marked us as SEEN, so we
|
|
* only need to handle any progress reporting here.
|
|
*/
|
|
-static void mark_object(struct object *obj, const struct name_path *path,
|
|
+static void mark_object(struct object *obj, struct strbuf *path,
|
|
const char *name, void *data)
|
|
{
|
|
update_progress(data);
|
|
diff --git a/revision.c b/revision.c
|
|
index 8dd09508ab88..3c8478181644 100644
|
|
--- a/revision.c
|
|
+++ b/revision.c
|
|
@@ -25,17 +25,17 @@ volatile show_early_output_fn_t show_early_output;
|
|
static const char *term_bad;
|
|
static const char *term_good;
|
|
|
|
-char *path_name(const struct name_path *path, const char *name)
|
|
+char *path_name(struct strbuf *path, const char *name)
|
|
{
|
|
struct strbuf ret = STRBUF_INIT;
|
|
if (path)
|
|
- strbuf_addbuf(&ret, path->base);
|
|
+ strbuf_addbuf(&ret, path);
|
|
strbuf_addstr(&ret, name);
|
|
return strbuf_detach(&ret, NULL);
|
|
}
|
|
|
|
void show_object_with_name(FILE *out, struct object *obj,
|
|
- const struct name_path *path, const char *component)
|
|
+ struct strbuf *path, const char *component)
|
|
{
|
|
char *name = path_name(path, component);
|
|
char *p;
|
|
diff --git a/revision.h b/revision.h
|
|
index 2a26310d6cc0..7beab15248f6 100644
|
|
--- a/revision.h
|
|
+++ b/revision.h
|
|
@@ -257,14 +257,10 @@ extern void put_revision_mark(const struct rev_info *revs,
|
|
extern void mark_parents_uninteresting(struct commit *commit);
|
|
extern void mark_tree_uninteresting(struct tree *tree);
|
|
|
|
-struct name_path {
|
|
- struct strbuf *base;
|
|
-};
|
|
-
|
|
-char *path_name(const struct name_path *path, const char *name);
|
|
+char *path_name(struct strbuf *path, const char *name);
|
|
|
|
extern void show_object_with_name(FILE *, struct object *,
|
|
- const struct name_path *, const char *);
|
|
+ struct strbuf *, const char *);
|
|
|
|
extern void add_pending_object(struct rev_info *revs,
|
|
struct object *obj, const char *name);
|
|
--
|
|
2.7.3
|
|
|