git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] http-push: fix off-by-path_len
@ 2009-01-17 15:36 Johannes Schindelin
  2009-01-17 15:40 ` Where's Nick?, was " Johannes Schindelin
                   ` (2 more replies)
  0 siblings, 3 replies; 33+ messages in thread
From: Johannes Schindelin @ 2009-01-17 15:36 UTC (permalink / raw)
  To: Kirill A. Korinskiy, git, gitster; +Cc: Mike Hommey, Ray Chuan, Nick Hengeveld


When getting the result of remote_ls(), we were advancing the variable
"path" to the relative path inside the repository.

However, then we went on to malloc a bogus amount of memory: we were
subtracting the prefix length _again_, quite possibly getting something
negative, which xmalloc() interprets as really, really much.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---

	Note that the push in t5540 is still broken, as http-push does
	not handle packed-refs (when looking what branches are on the 
	remote side).

	It should not even try to access the directory structure under
	refs/ to begin with, but read info/refs instead.

	However, that is just one example of the ugliness that is 
	http-push.c; it also seems to be a perfect example of a copy-pasting 
	hell; just look at the output of "git grep
	curl_easy_setopt http-push.c".

	There _has_ to be lot of room for improvement.

 http-push.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/http-push.c b/http-push.c
index 9fcccee..cb5bf95 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1435,10 +1435,8 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
 			}
 			if (path) {
 				path += remote->path_len;
+				ls->dentry_name = xstrdup(path);
 			}
-			ls->dentry_name = xmalloc(strlen(path) -
-						  remote->path_len + 1);
-			strcpy(ls->dentry_name, path + remote->path_len);
 		} else if (!strcmp(ctx->name, DAV_PROPFIND_COLLECTION)) {
 			ls->dentry_flags |= IS_DIR;
 		}
@@ -1449,6 +1447,12 @@ static void handle_remote_ls_ctx(struct xml_ctx *ctx, int tag_closed)
 	}
 }
 
+/*
+ * NEEDSWORK: remote_ls() ignores info/refs on the remote side.  But it
+ * should _only_ heed the information from that file, instead of trying to
+ * determine the refs from the remote file system (badly: it does not even
+ * know about packed-refs).
+ */
 static void remote_ls(const char *path, int flags,
 		      void (*userFunc)(struct remote_ls_ctx *ls),
 		      void *userData)
-- 
1.6.1.325.g062d4

^ permalink raw reply related	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2009-01-18 21:12 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-17 15:36 [PATCH] http-push: fix off-by-path_len Johannes Schindelin
2009-01-17 15:40 ` Where's Nick?, was " Johannes Schindelin
2009-01-17 15:41 ` [PATCH] t5540: clarify that http-push does not handle packed-refs on the remote Johannes Schindelin
2009-01-18  7:49 ` [PATCH] http-push: fix off-by-path_len Mike Hommey
2009-01-18  8:04   ` [WIP Patch 00/12] Refactoring the http API Mike Hommey
2009-01-18  8:04     ` [WIP Patch 01/12] Don't expect verify_pack() callers to set pack_size Mike Hommey
2009-01-18  8:04       ` [WIP Patch 02/12] Some cleanup in get_refs_via_curl() Mike Hommey
2009-01-18  8:04         ` [WIP Patch 03/12] Two new functions for the http API Mike Hommey
2009-01-18  8:04           ` [WIP Patch 04/12] Use the new http API in http_fetch_ref() Mike Hommey
2009-01-18  8:04             ` [WIP Patch 05/12] Use the new http API in get_refs_via_curl() Mike Hommey
2009-01-18  8:04               ` [WIP Patch 06/12] Use the new http API in http-walker.c:fetch_indices() Mike Hommey
2009-01-18  8:04                 ` [WIP Patch 07/12] Use the new http API in http-push.c:fetch_indices() Mike Hommey
2009-01-18  8:04                   ` [WIP Patch 08/12] Use the new http API in update_remote_info_refs() Mike Hommey
2009-01-18  8:04                     ` [WIP Patch 09/12] Use the new http API in fetch_symref() Mike Hommey
2009-01-18  8:04                       ` [WIP Patch 10/12] Use the new http API in http-walker.c:fetch_index() Mike Hommey
2009-01-18  8:04                         ` [WIP Patch 11/12] Use the new http API in http-push.c:fetch_index() Mike Hommey
2009-01-18  8:04                           ` [WIP Patch 12/12] Use the new http API in http-walker.c:fetch_pack() Mike Hommey
2009-01-18 15:18                     ` [WIP Patch 08/12] Use the new http API in update_remote_info_refs() Johannes Schindelin
2009-01-18 19:23                       ` Mike Hommey
2009-01-18 15:14                   ` [WIP Patch 07/12] Use the new http API in http-push.c:fetch_indices() Johannes Schindelin
2009-01-18 15:12               ` [WIP Patch 05/12] Use the new http API in get_refs_via_curl() Johannes Schindelin
2009-01-18 15:10             ` [WIP Patch 04/12] Use the new http API in http_fetch_ref() Johannes Schindelin
2009-01-18 19:21               ` Mike Hommey
2009-01-18 15:03           ` [WIP Patch 03/12] Two new functions for the http API Johannes Schindelin
2009-01-18 19:06         ` [WIP Patch 02/12] Some cleanup in get_refs_via_curl() Johannes Schindelin
2009-01-18 19:11           ` Johannes Schindelin
2009-01-18 19:30             ` Mike Hommey
2009-01-18 21:09               ` Johannes Schindelin
2009-01-18 19:19           ` Mike Hommey
2009-01-18 21:10             ` Johannes Schindelin
2009-01-18  8:30     ` [WIP Patch 00/12] Refactoring the http API Junio C Hamano
2009-01-18  9:12       ` Mike Hommey
2009-01-18 11:29         ` Boyd Stephen Smith Jr.

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).