Skip to content
Snippets Groups Projects
Commit e7f2f638 authored by Jan Včelák's avatar Jan Včelák :rocket:
Browse files

static buffer and error checking for DNSSEC status

CID: 1094066
parent db583498
No related branches found
No related tags found
No related merge requests found
......@@ -222,12 +222,18 @@ static int remote_c_status(server_t *s, remote_cmdargs_t* a)
return KNOT_EOK;
}
static char *dnssec_info(const zonedata_t *zd, char *buf)
static char *dnssec_info(const zonedata_t *zd, char *buf, size_t buf_size)
{
assert(zd && zd->dnssec_timer);
assert(buf);
time_t diff_time = zd->dnssec_timer->tv.tv_sec;
struct tm *t = localtime(&diff_time);
snprintf(buf, 128, "%s", asctime(t));
int written = snprintf(buf, buf_size, "%s", asctime(t));
UNUSED(written);
assert(written >= 0);
return buf;
}
......@@ -301,8 +307,8 @@ static int remote_c_zonestatus(server_t *s, remote_cmdargs_t* a)
}
/* Workaround, some platforms ignore 'size' with snprintf() */
char buf[512];
char *dnssec_buf = xmalloc(128);
char buf[512] = { '\0' };
char dnssec_buf[128] = { '\0' };
int n = snprintf(buf, sizeof(buf),
"%s\ttype=%s | serial=%u | %s %s | %s %s\n",
zd->conf->name,
......@@ -311,9 +317,8 @@ static int remote_c_zonestatus(server_t *s, remote_cmdargs_t* a)
state ? state : "",
when ? when : "",
zd->conf->dnssec_enable ? "automatic DNSSEC, resigning at:" : "",
zd->conf->dnssec_enable ? dnssec_info(zd, dnssec_buf) : "");
zd->conf->dnssec_enable ? dnssec_info(zd, dnssec_buf, sizeof(dnssec_buf)) : "");
free(when);
free(dnssec_buf);
if (n < 0 || (size_t)n > rb) {
*dst = '\0';
ret = KNOT_ESPACE;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment