From: André Goddard Rosa <hidden> Date: 2016-06-15 22:43:53
Hi, all!
Please cc: me as I'm not subscribed. I'm sending the patch inline
only for review, probably it is mangled.
Please use the attached patch if you agree with it. Sorry about
sending it attached.
From b2af9e783e7d8974b969c01f7a2de07b9cd5cf70 Mon Sep 17 00:00:00 2001
From: Andre Goddard Rosa <redacted>
Date: Tue, 27 Nov 2007 10:14:57 -0200
Subject: [PATCH] Fix segmentation fault when user doesn't have access
permission to the repository.
When trying to "git-pull" with my personal user in a tree owned by root,
git was crashing with segmentation fault.
Signed-off-by: Andre Goddard Rosa <redacted>
---
builtin-fetch--tool.c | 12 ++++++++++--
builtin-fetch.c | 14 +++++++++++---
2 files changed, 21 insertions(+), 5 deletions(-)
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport, die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */- if (!append)- fclose(fopen(git_path("FETCH_HEAD"), "w"));+ if (!append) {+ char *filename = git_path("FETCH_HEAD");+ int fd = fopen(filename, "w");+ if (!fd)+ return error("cannot open %s: %s\n", filename, strerror(errno));+ fclose(fd);+ } ref_map = get_ref_map(transport, refs, ref_count, tags, &autotags);
From: Alex Riesen <hidden> Date: 2016-06-15 22:43:53
André Goddard Rosa, Thu, Nov 22, 2007 01:59:00 +0100:
quoted hunk
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport, die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */- if (!append)- fclose(fopen(git_path("FETCH_HEAD"), "w"));+ if (!append) {+ char *filename = git_path("FETCH_HEAD");+ int fd = fopen(filename, "w");
From: André Goddard Rosa <hidden> Date: 2016-06-15 22:43:53
On Nov 22, 2007 2:09 PM, Alex Riesen [off-list ref] wrote:
André Goddard Rosa, Thu, Nov 22, 2007 01:59:00 +0100:
quoted
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport, die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */- if (!append)- fclose(fopen(git_path("FETCH_HEAD"), "w"));+ if (!append) {+ char *filename = git_path("FETCH_HEAD");+ int fd = fopen(filename, "w");
This should have been "FILE *fp", not "int fd".
Hi, Alex!
Many thanks, you're right.
I tested it here before posting but luckly (or not, as I didn't catch
this when compiling) it worked,
as a pointer have the sizeof(int) in my x86 platform. >:|
Would you please comment on the attached patch and see if it's ok?
From dbadc5213b9957fb575c6da8528e5dd7a3f1f43e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Goddard=20Rosa?= <redacted>
Date: Thu, 22 Nov 2007 20:22:23 -0200
Subject: [PATCH] Fix segmentation fault when user doesn't have access
permission to the repository.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Signed-off-by: André Goddard Rosa <redacted>
---
builtin-fetch--tool.c | 12 ++++++++++--
builtin-fetch.c | 21 ++++++++++++++++-----
2 files changed, 26 insertions(+), 7 deletions(-)
From: André Goddard Rosa <hidden> Date: 2016-06-15 22:43:53
On Nov 22, 2007 2:09 PM, Alex Riesen [off-list ref] wrote:
André Goddard Rosa, Thu, Nov 22, 2007 01:59:00 +0100:
quoted
@@ -487,8 +490,13 @@ static int do_fetch(struct transport *transport, die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */- if (!append)- fclose(fopen(git_path("FETCH_HEAD"), "w"));+ if (!append) {+ char *filename = git_path("FETCH_HEAD");+ int fd = fopen(filename, "w");
This should have been "FILE *fp", not "int fd".
Hi, Alex!
Many thanks, you're right.
I tested it here before posting but luckly (or not, as I didn't catch
this when compiling) it worked,
as a pointer have the sizeof(int) in my x86 platform. >:|
Would you please comment on the attached patch and see if it's ok?
From dbadc5213b9957fb575c6da8528e5dd7a3f1f43e Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Andr=C3=A9=20Goddard=20Rosa?= <redacted>
Date: Thu, 22 Nov 2007 20:22:23 -0200
Subject: [PATCH] Fix segmentation fault when user doesn't have access
permission to the repository.
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Signed-off-by: André Goddard Rosa <redacted>
---
builtin-fetch--tool.c | 12 ++++++++++--
builtin-fetch.c | 21 ++++++++++++++++-----
2 files changed, 26 insertions(+), 7 deletions(-)
@@ -404,7 +410,7 @@ static int fetch_refs(struct transport *transport,
struct ref *ref_map)
if (ret)
ret = transport_fetch_refs(transport, ref_map);
if (!ret)
- store_updated_refs(transport->url, ref_map);
+ ret |= store_updated_refs(transport->url, ref_map);
transport_unlock_pack(transport);
return ret;
}
@@ -487,8 +493,13 @@ static int do_fetch(struct transport *transport, die("Don't know how to fetch from %s", transport->url); /* if not appending, truncate FETCH_HEAD */- if (!append)- fclose(fopen(git_path("FETCH_HEAD"), "w"));+ if (!append) {+ char *filename = git_path("FETCH_HEAD");+ FILE *fp = fopen(filename, "w");+ if (!fp)+ return error("cannot open %s: %s\n", filename,