extern int do_updatedb(CA_DB *db, time_t *now);
void app_bail_out(char *fmt, ...);
+/**
+ * OPENSSL_malloc() wrapper that bails out with a meaningful message on failure.
+ *
+ * @param sz Number of bytes to allocate.
+ * @param what Description of the object being allocated.
+ * @return On success, returns a pointer to the newly allocated memory.
+ * on failure, calls app_bail_out() to terminate the program.
+ */
void *app_malloc(size_t sz, const char *what);
+/**
+ * OPENSSL_malloc_array() wrapper that bails out with a meaningful message
+ * on failure.
+ *
+ * @param n Number of objects to allocate memory for.
+ * @param sz Size in bytes of each object to be allocated.
+ * @param what Description of the array being allocated.
+ * @return On success, returns a pointer to the newly allocated memory;
+ * on failure, calls app_bail_out() to terminate the program.
+ */
+void *app_malloc_array(size_t n, size_t sz, const char *what);
/* load_serial, save_serial, and rotate_serial are also used for CRL numbers */
BIGNUM *load_serial(const char *serialfile, int *exists, int create,
return vp;
}
+void *app_malloc_array(size_t n, size_t sz, const char *what)
+{
+ void *vp = OPENSSL_malloc_array(n, sz);
+
+ if (vp == NULL)
+ app_bail_out("%s: Could not allocate %zu*%zu bytes for %s\n",
+ opt_getprog(), n, sz, what);
+ return vp;
+}
+
char *next_item(char *opt) /* in list separated by comma and/or space */
{
/* advance to separator (comma or whitespace), if any */
return vp;
}
+void *app_malloc_array(size_t n, size_t sz, const char *what)
+{
+ void *vp;
+
+ /*
+ * Instead of exiting with a failure, abort() is called which makes sure
+ * that there will be a good stack trace for debugging purposes.
+ */
+ if (!TEST_ptr(vp = OPENSSL_malloc_array(n, sz))) {
+ TEST_info("Could not allocate %zu*%zu bytes for %s\n", n, sz, what);
+ abort();
+ }
+ return vp;
+}
+
/* shim to prevent sucking in too much from apps */
int opt_legacy_okay(void)