asn1: Fix warnings

This commit is contained in:
Nicolas Williams
2021-03-03 10:15:18 -06:00
parent a68ccb6693
commit fb5ae095e9
3 changed files with 22 additions and 14 deletions

View File

@@ -357,7 +357,7 @@ dotype(unsigned char *buf, size_t len, char **argv, size_t *size)
size_t matches = 0;
size_t sz;
size_t i = 0;
char *s;
char *s = NULL;
void *v;
int ret = 0;

View File

@@ -175,17 +175,21 @@ segv_handler(int sig)
{
int fd;
char msg[] = "SIGSEGV i current test: ";
/* For compilers that insist we check write(2)'s result here */
int e = 1;
fd = open("/dev/stdout", O_WRONLY, 0600);
if (fd >= 0) {
write(fd, msg, sizeof(msg));
write(fd, current_test, strlen(current_test));
write(fd, " ", 1);
write(fd, current_state, strlen(current_state));
write(fd, "\n", 1);
close(fd);
if (write(fd, msg, sizeof(msg)) == -1 ||
write(fd, current_test, strlen(current_test)) == -1 ||
write(fd, " ", 1) == -1 ||
write(fd, current_state, strlen(current_state)) == -1 ||
write(fd, "\n", 1) == -1)
e = 2;
(void) close(fd);
}
_exit(1);
_exit(e);
}
int

View File

@@ -597,6 +597,7 @@ _heim_time2generalizedtime (time_t t, heim_octet_string *s, int gtimep)
{
struct tm tm;
const size_t len = gtimep ? 15 : 13;
int bytes;
s->data = NULL;
s->length = 0;
@@ -607,13 +608,16 @@ _heim_time2generalizedtime (time_t t, heim_octet_string *s, int gtimep)
return ENOMEM;
s->length = len;
if (gtimep)
snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
bytes = snprintf(s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ",
tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
else
snprintf (s->data, len + 1, "%02d%02d%02d%02d%02d%02dZ",
tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
bytes = snprintf(s->data, len + 1, "%02d%02d%02d%02d%02d%02dZ",
tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
if (bytes > len)
abort();
return 0;
}