summaryrefslogtreecommitdiff
path: root/http-fetch.c
diff options
context:
space:
mode:
authorPeter Eriksen <s022018@student.dtu.dk>2006-06-11 14:03:28 +0200
committerJunio C Hamano <junkio@cox.net>2006-06-16 22:45:12 -0700
commitbfbd0bb6ecbbbf75a5caaff6afaf5a6af8fa518e (patch)
tree52f36804599a41eafa3a020f06dbe118c6f652f9 /http-fetch.c
parent5996ca0836e21ab4e6be0a16a615eff965f18b8b (diff)
downloadgit-bfbd0bb6ecbbbf75a5caaff6afaf5a6af8fa518e.tar.gz
Implement safe_strncpy() as strlcpy() and use it more.
Signed-off-by: Peter Eriksen <s022018@student.dtu.dk> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'http-fetch.c')
-rw-r--r--http-fetch.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/http-fetch.c b/http-fetch.c
index d3602b7d7d..da1a7f5416 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -584,10 +584,8 @@ static void process_alternates_response(void *callback_data)
// skip 'objects' at end
if (okay) {
target = xmalloc(serverlen + posn - i - 6);
- strncpy(target, base, serverlen);
- strncpy(target + serverlen, data + i,
- posn - i - 7);
- target[serverlen + posn - i - 7] = '\0';
+ safe_strncpy(target, base, serverlen);
+ safe_strncpy(target + serverlen, data + i, posn - i - 6);
if (get_verbosely)
fprintf(stderr,
"Also look at %s\n", target);
@@ -728,8 +726,8 @@ xml_cdata(void *userData, const XML_Char *s, int len)
struct xml_ctx *ctx = (struct xml_ctx *)userData;
if (ctx->cdata)
free(ctx->cdata);
- ctx->cdata = xcalloc(len+1, 1);
- strncpy(ctx->cdata, s, len);
+ ctx->cdata = xmalloc(len + 1);
+ safe_strncpy(ctx->cdata, s, len + 1);
}
static int remote_ls(struct alt_base *repo, const char *path, int flags,