apps_shims.c 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Copyright 2019-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdlib.h>
  10. #include "apps.h"
  11. #include "../testutil.h"
  12. /* shim that avoids sucking in too much from apps/apps.c */
  13. void *app_malloc(size_t sz, const char *what)
  14. {
  15. void *vp;
  16. /*
  17. * This isn't ideal but it is what the app's app_malloc() does on failure.
  18. * Instead of exiting with a failure, abort() is called which makes sure
  19. * that there will be a good stack trace for debugging purposes.
  20. */
  21. if (!TEST_ptr(vp = OPENSSL_malloc(sz))) {
  22. TEST_info("Could not allocate %zu bytes for %s\n", sz, what);
  23. abort();
  24. }
  25. return vp;
  26. }
  27. /* shim to prevent sucking in too much from apps */
  28. int opt_legacy_okay(void)
  29. {
  30. return 1;
  31. }
  32. /*
  33. * These three functions are defined here so that they don't need to come from
  34. * the apps source code and pull in a lot of additional things.
  35. */
  36. int opt_provider_option_given(void)
  37. {
  38. return 0;
  39. }
  40. const char *app_get0_propq(void)
  41. {
  42. return NULL;
  43. }
  44. OSSL_LIB_CTX *app_get0_libctx(void)
  45. {
  46. return NULL;
  47. }