OSDN Git Service

Merge branch 'jk/xstrfmt'
authorJunio C Hamano <gitster@pobox.com>
Wed, 9 Jul 2014 18:34:05 +0000 (11:34 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 9 Jul 2014 18:34:05 +0000 (11:34 -0700)
* jk/xstrfmt:
  setup_git_env(): introduce git_path_from_env() helper
  unique_path: fix unlikely heap overflow
  walker_fetch: fix minor memory leak
  merge: use argv_array when spawning merge strategy
  sequencer: use argv_array_pushf
  setup_git_env: use git_pathdup instead of xmalloc + sprintf
  use xstrfmt to replace xmalloc + strcpy/strcat
  use xstrfmt to replace xmalloc + sprintf
  use xstrdup instead of xmalloc + strcpy
  use xstrfmt in favor of manual size calculations
  strbuf: add xstrfmt helper

1  2 
builtin/apply.c
builtin/fetch.c
builtin/fmt-merge-msg.c
http-push.c
merge-recursive.c
remote.c
sequencer.c
sha1_name.c
unpack-trees.c

diff --cc builtin/apply.c
Simple merge
diff --cc builtin/fetch.c
Simple merge
Simple merge
diff --cc http-push.c
@@@ -763,15 -767,13 +763,13 @@@ static void handle_new_lock_ctx(struct 
  
        if (tag_closed && ctx->cdata) {
                if (!strcmp(ctx->name, DAV_ACTIVELOCK_OWNER)) {
-                       lock->owner = xmalloc(strlen(ctx->cdata) + 1);
-                       strcpy(lock->owner, ctx->cdata);
+                       lock->owner = xstrdup(ctx->cdata);
                } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TIMEOUT)) {
 -                      if (starts_with(ctx->cdata, "Second-"))
 -                              lock->timeout =
 -                                      strtol(ctx->cdata + 7, NULL, 10);
 +                      const char *arg;
 +                      if (skip_prefix(ctx->cdata, "Second-", &arg))
 +                              lock->timeout = strtol(arg, NULL, 10);
                } else if (!strcmp(ctx->name, DAV_ACTIVELOCK_TOKEN)) {
-                       lock->token = xmalloc(strlen(ctx->cdata) + 1);
-                       strcpy(lock->token, ctx->cdata);
+                       lock->token = xstrdup(ctx->cdata);
  
                        git_SHA1_Init(&sha_ctx);
                        git_SHA1_Update(&sha_ctx, lock->token, strlen(lock->token));
@@@ -1567,13 -1553,9 +1561,10 @@@ static int remote_exists(const char *pa
  
  static void fetch_symref(const char *path, char **symref, unsigned char *sha1)
  {
-       char *url;
+       char *url = xstrfmt("%s%s", repo->url, path);
        struct strbuf buffer = STRBUF_INIT;
 +      const char *name;
  
-       url = xmalloc(strlen(repo->url) + strlen(path) + 1);
-       sprintf(url, "%s%s", repo->url, path);
        if (http_get_strbuf(url, &buffer, NULL) != HTTP_OK)
                die("Couldn't get %s for remote symref\n%s", url,
                    curl_errorstr);
Simple merge
diff --cc remote.c
Simple merge
diff --cc sequencer.c
Simple merge
diff --cc sha1_name.c
Simple merge
diff --cc unpack-trees.c
Simple merge