/*
* NSS crypto backend implementation
*
- * Copyright (C) 2010-2020 Red Hat, Inc. All rights reserved.
- * Copyright (C) 2010-2020 Milan Broz
+ * Copyright (C) 2010-2021 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2021 Milan Broz
*
* This file is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
int crypt_backend_init(void)
{
+ int r;
+
if (crypto_backend_initialised)
return 0;
return -EINVAL;
#if HAVE_DECL_NSS_GETVERSION
- snprintf(version, 64, "NSS %s", NSS_GetVersion());
+ r = snprintf(version, sizeof(version), "NSS %s", NSS_GetVersion());
#else
- snprintf(version, 64, "NSS");
+ r = snprintf(version, sizeof(version), "NSS");
#endif
+ if (r < 0 || (size_t)r >= sizeof(version))
+ return -EINVAL;
+
crypto_backend_initialised = 1;
return 0;
}