summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2019-05-14 21:39:46 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2019-05-14 21:42:28 +0200
commitbb31860b6e034e99d75173ed39e72e2b3a6ebe66 (patch)
treec1ff24cbd587eea3b8f583780010fc055a7d0897 /src
parent3cc7043df62cf20f908316fefdc065e946eebfa3 (diff)
downloadgnutls-bb31860b6e034e99d75173ed39e72e2b3a6ebe66.tar.gz
Check all memory allocation in examples and certtooltmp-check-allocations
Resolves: #739 Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Diffstat (limited to 'src')
-rw-r--r--src/certtool-cfg.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/certtool-cfg.c b/src/certtool-cfg.c
index 3cf9aef55f..8e8b8b59c8 100644
--- a/src/certtool-cfg.c
+++ b/src/certtool-cfg.c
@@ -65,6 +65,12 @@ extern int ask_pass;
#define MAX_ENTRIES 128
#define MAX_POLICIES 8
+#define CHECK_MALLOC(x) \
+ if (x == NULL) { \
+ fprintf(stderr, "memory error\n"); \
+ exit(1); \
+ }
+
#define PRINT_TIME_T_ERROR \
if (sizeof(time_t) < 8) \
fprintf(stderr, "This system expresses time with a 32-bit time_t; that prevents dates after 2038 to be expressed by GnuTLS.\n")
@@ -245,6 +251,7 @@ void cfg_init(void)
if (s_name == NULL) { \
i = 0; \
s_name = malloc(sizeof(char*)*MAX_ENTRIES); \
+ CHECK_MALLOC(s_name); \
do { \
if (val && strcmp(val->pzName, name)!=0) \
continue; \
@@ -266,10 +273,12 @@ void cfg_init(void)
if (s_name == NULL) { \
i = 0; \
s_name = malloc(sizeof(char*)*MAX_ENTRIES); \
+ CHECK_MALLOC(s_name); \
do { \
if (val && strcmp(val->pzName, name)!=0) \
continue; \
str = strdup(val->v.strVal); \
+ CHECK_MALLOC(str); \
if ((p=strchr(str, ' ')) == NULL && (p=strchr(str, '\t')) == NULL) { \
fprintf(stderr, "Error parsing %s\n", name); \
exit(1); \