diff options
Diffstat (limited to 'pkcs11/gkm/gkm-attributes.c')
-rw-r--r-- | pkcs11/gkm/gkm-attributes.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/pkcs11/gkm/gkm-attributes.c b/pkcs11/gkm/gkm-attributes.c index dfdd08f3..69320ffb 100644 --- a/pkcs11/gkm/gkm-attributes.c +++ b/pkcs11/gkm/gkm-attributes.c @@ -28,6 +28,7 @@ #include <stdarg.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> @@ -216,15 +217,18 @@ gkm_attribute_set_date (CK_ATTRIBUTE_PTR attr, time_t time) g_return_val_if_reached (CKR_GENERAL_ERROR); g_assert (sizeof (date.year) == 4); - snprintf ((char*)buf, 5, "%04d", 1900 + tm.tm_year); + if (G_UNLIKELY (snprintf ((char*)buf, 5, "%04d", 1900 + tm.tm_year) < 0)) + abort (); memcpy (date.year, buf, 4); g_assert (sizeof (date.month) == 2); - snprintf ((char*)buf, 3, "%02d", tm.tm_mon + 1); + if (G_UNLIKELY (snprintf ((char*)buf, 3, "%02d", tm.tm_mon + 1) < 0)) + abort (); memcpy (date.month, buf, 2); g_assert (sizeof (date.day) == 2); - snprintf ((char*)buf, 3, "%02d", tm.tm_mday); + if (G_UNLIKELY (snprintf ((char*)buf, 3, "%02d", tm.tm_mday) < 0)) + abort (); memcpy (date.day, buf, 2); return gkm_attribute_set_data (attr, &date, sizeof (date)); |