summaryrefslogtreecommitdiff
path: root/sbin/isakmpd/cert.c
diff options
context:
space:
mode:
authorNiklas Hallqvist <niklas@cvs.openbsd.org>1999-04-19 19:57:30 +0000
committerNiklas Hallqvist <niklas@cvs.openbsd.org>1999-04-19 19:57:30 +0000
commitfd9ea1a7de928e4ce792a4f547165ab0181a8f86 (patch)
tree1bf5872a7c692b55414808ba0ac6af15bda95daf /sbin/isakmpd/cert.c
parent230bd89c7b66900b76cc34a000c1f8fd76dadf41 (diff)
./cert.c: Merge with EOM 1.10
./x509.c: Merge with EOM 1.13 Style Style. alloc error reporting. Math error propagation. Allocate right sizes. 1999 copyrights
Diffstat (limited to 'sbin/isakmpd/cert.c')
-rw-r--r--sbin/isakmpd/cert.c39
1 files changed, 22 insertions, 17 deletions
diff --git a/sbin/isakmpd/cert.c b/sbin/isakmpd/cert.c
index ade80c2dd46..3836bb8375e 100644
--- a/sbin/isakmpd/cert.c
+++ b/sbin/isakmpd/cert.c
@@ -1,8 +1,9 @@
-/* $OpenBSD: cert.c,v 1.8 1999/02/26 03:34:02 niklas Exp $ */
-/* $EOM: cert.c,v 1.7 1999/02/25 11:38:45 niklas Exp $ */
+/* $OpenBSD: cert.c,v 1.9 1999/04/19 19:57:29 niklas Exp $ */
+/* $EOM: cert.c,v 1.10 1999/04/18 15:17:23 niklas Exp $ */
/*
* Copyright (c) 1998 Niels Provos. All rights reserved.
+ * Copyright (c) 1999 Niklas Hallqvist. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -42,12 +43,15 @@
#include "cert.h"
#include "isakmp_num.h"
+#include "log.h"
#include "x509.h"
struct cert_handler cert_handler[] = {
- {ISAKMP_CERTENC_X509_SIG,
- x509_certreq_validate, x509_certreq_decode, x509_free_aca,
- x509_cert_obtain, x509_cert_get_key, x509_cert_get_subject}
+ {
+ ISAKMP_CERTENC_X509_SIG,
+ x509_certreq_validate, x509_certreq_decode, x509_free_aca,
+ x509_cert_obtain, x509_cert_get_key, x509_cert_get_subject
+ }
};
struct cert_handler *
@@ -58,20 +62,19 @@ cert_get (u_int16_t id)
for (i = 0; i < sizeof cert_handler / sizeof cert_handler[0]; i++)
if (id == cert_handler[i].id)
return &cert_handler[i];
- return NULL;
+ return 0;
}
-
-/* Decode a CERTREQ and return a parsed structure */
-
+/* Decode a CERTREQ and return a parsed structure. */
struct certreq_aca *
certreq_decode (u_int16_t type, u_int8_t *data, u_int32_t datalen)
{
struct cert_handler *handler;
struct certreq_aca aca, *ret;
- if ((handler = cert_get (type)) == NULL)
- return NULL;
+ handler = cert_get (type);
+ if (!handler)
+ return 0;
aca.id = type;
aca.handler = handler;
@@ -79,19 +82,21 @@ certreq_decode (u_int16_t type, u_int8_t *data, u_int32_t datalen)
if (datalen > 0)
{
aca.data = handler->certreq_decode (data, datalen);
- if (aca.data == NULL)
- return NULL;
+ if (!aca.data)
+ return 0;
}
else
- aca.data = NULL;
+ aca.data = 0;
- if ((ret = malloc (sizeof (aca))) == NULL)
+ ret = malloc (sizeof aca);
+ if (!ret)
{
+ log_error ("certreq_decode: malloc (%d) failed", sizeof aca);
handler->free_aca (aca.data);
- return NULL;
+ return 0;
}
- memcpy (ret, &aca, sizeof (aca));
+ memcpy (ret, &aca, sizeof aca);
return ret;
}