summaryrefslogtreecommitdiff
path: root/sbin/isakmpd/conf.c
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-05-26 02:38:36 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-05-26 02:38:36 +0000
commit1afcbbb82d75b84443f4540bba4e945f215a4da2 (patch)
tree3ded4ded68a06a5124415b02eb0d486865e54da4 /sbin/isakmpd/conf.c
parent5dc5b41421448ab1c7733130bc329a4fb328daba (diff)
Handle strdup returning NULL. OK hshoexer
Diffstat (limited to 'sbin/isakmpd/conf.c')
-rw-r--r--sbin/isakmpd/conf.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/sbin/isakmpd/conf.c b/sbin/isakmpd/conf.c
index c6ac27372f6..c19bef066f3 100644
--- a/sbin/isakmpd/conf.c
+++ b/sbin/isakmpd/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.82 2005/04/08 22:32:09 cloder Exp $ */
+/* $OpenBSD: conf.c,v 1.83 2005/05/26 02:38:35 cloder Exp $ */
/* $EOM: conf.c,v 1.48 2000/12/04 02:04:29 angelos Exp $ */
/*
@@ -197,15 +197,33 @@ conf_set_now(char *section, char *tag, char *value, int override,
(unsigned long)sizeof *node);
return 1;
}
- node->section = strdup(section);
- node->tag = strdup(tag);
- node->value = strdup(value);
+ node->section = node->tag = node->value = NULL;
+ if ((node->section = strdup(section)) == NULL)
+ goto fail;
+ if ((node->tag = strdup(tag)) == NULL)
+ goto fail;
+ if ((node->value = strdup(value)) == NULL)
+ goto fail;
node->is_default = is_default;
LIST_INSERT_HEAD(&conf_bindings[conf_hash(section)], node, link);
LOG_DBG((LOG_MISC, 95, "conf_set_now: [%s]:%s->%s", node->section,
node->tag, node->value));
return 0;
+fail:
+ if (node->value) {
+ free(node->value);
+ node->value = NULL;
+ }
+ if (node->tag) {
+ free(node->tag);
+ node->tag = NULL;
+ }
+ if (node->section) {
+ free(node->section);
+ node->section = NULL;
+ }
+ return 1;
}
/*