Code

Catch invalid --depth option passed to clone or fetch
[git.git] / transport.c
index c9c8056f9de69bd378cd271d70363b5560f13e07..7bfbf31f6b9a84d5e77a8d2cc59103b2dc0c3105 100644 (file)
@@ -472,8 +472,12 @@ static int set_git_option(struct git_transport_options *opts,
        } else if (!strcmp(name, TRANS_OPT_DEPTH)) {
                if (!value)
                        opts->depth = 0;
-               else
-                       opts->depth = atoi(value);
+               else {
+                       char *end;
+                       opts->depth = strtol(value, &end, 0);
+                       if (*end)
+                               die("transport: invalid depth option '%s'", value);
+               }
                return 0;
        }
        return 1;