summaryrefslogtreecommitdiff
path: root/src/transports/cred.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-02-09 23:41:13 -0500
committerEdward Thomson <ethomson@edwardthomson.com>2015-02-12 22:54:46 -0500
commit392702ee2c88d7d8aaff25f7a84acb73606f9094 (patch)
tree97a66fe6e488797c6a9c2680ccb31964f61fe340 /src/transports/cred.c
parentd24a5312d8ab6d3cdb259e450ec9f1e2e6f3399d (diff)
downloadlibgit2-392702ee2c88d7d8aaff25f7a84acb73606f9094.tar.gz
allocations: test for overflow of requested size
Introduce some helper macros to test integer overflow from arithmetic and set error message appropriately.
Diffstat (limited to 'src/transports/cred.c')
-rw-r--r--src/transports/cred.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/transports/cred.c b/src/transports/cred.c
index 1b4d29c0a..8e5447d18 100644
--- a/src/transports/cred.c
+++ b/src/transports/cred.c
@@ -311,6 +311,9 @@ int git_cred_username_new(git_cred **cred, const char *username)
assert(cred);
len = strlen(username);
+
+ GITERR_CHECK_ALLOC_ADD(sizeof(git_cred_username), len);
+ GITERR_CHECK_ALLOC_ADD(sizeof(git_cred_username) + len, 1);
c = git__malloc(sizeof(git_cred_username) + len + 1);
GITERR_CHECK_ALLOC(c);