]> git.proxmox.com Git - libgit2.git/commitdiff
git_libgit2_opts: introduce `GIT_OPT_ENABLE_STRICT_OBJECT_CREATION`
authorEdward Thomson <ethomson@github.com>
Tue, 23 Feb 2016 04:46:50 +0000 (23:46 -0500)
committerEdward Thomson <ethomson@github.com>
Sun, 28 Feb 2016 17:38:39 +0000 (12:38 -0500)
include/git2/common.h
src/object.c
src/object.h
src/settings.c

index c26030840d0bcc959388837a6cfe342e31f89e68..4f43185f8f7dade7326f8a55a14ee91c084057a1 100644 (file)
@@ -147,6 +147,7 @@ typedef enum {
        GIT_OPT_SET_TEMPLATE_PATH,
        GIT_OPT_SET_SSL_CERT_LOCATIONS,
        GIT_OPT_SET_USER_AGENT,
+       GIT_OPT_ENABLE_STRICT_OBJECT_CREATION,
 } git_libgit2_opt_t;
 
 /**
@@ -251,6 +252,14 @@ typedef enum {
  *             > - `user_agent` is the value that will be delivered as the
  *             >   User-Agent header on HTTP requests.
  *
+ *     * opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, int enabled)
+ *
+ *             > Enable strict input validation when creating new objects
+ *             > to ensure that all inputs to the new objects are valid.  For
+ *             > example, when this is enabled, the parent(s) and tree inputs
+ *             > will be validated when creating a new commit.  This defaults
+ *             > to disabled.
+ *
  * @param option Option key
  * @param ... value to set the option
  * @return 0 on success, <0 on failure
index b0a8199bcb2d2495c60efad7ab39d9663ca23acd..7f7de9feeb8cf24879b1d71a428f91a920184395 100644 (file)
@@ -14,6 +14,8 @@
 #include "blob.h"
 #include "tag.h"
 
+bool git_object__strict_input_validation = false;
+
 typedef struct {
        const char      *str;   /* type name string */
        size_t          size;   /* size in bytes of the object structure */
index d187c55b7348de035d995352472619216f804ac5..358279a3ddf9b05e3512265b6a211886d30bfcb7 100644 (file)
@@ -7,6 +7,8 @@
 #ifndef INCLUDE_object_h__
 #define INCLUDE_object_h__
 
+extern bool git_object__strict_input_validation;
+
 /** Base git object for inheritance */
 struct git_object {
        git_cached_obj cached;
index d7341abe8fa41598a6065ada1a4c84f94a33f528..88602bad0d350cbfd44cf183c99fa0dd6c97c49f 100644 (file)
@@ -14,6 +14,7 @@
 #include "sysdir.h"
 #include "cache.h"
 #include "global.h"
+#include "object.h"
 
 void git_libgit2_version(int *major, int *minor, int *rev)
 {
@@ -181,6 +182,11 @@ int git_libgit2_opts(int key, ...)
                }
 
                break;
+
+       case GIT_OPT_ENABLE_STRICT_OBJECT_CREATION:
+               git_object__strict_input_validation = (va_arg(ap, int) != 0);
+               break;
+
        default:
                giterr_set(GITERR_INVALID, "invalid option key");
                error = -1;