mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-13 20:10:01 -04:00
fail if ctime() output is truncted
This commit is contained in:
parent
5debc374ce
commit
dde207c0b9
1 changed files with 13 additions and 5 deletions
|
|
@ -70,22 +70,30 @@ timedb_lookup(const char *zone, const char *name, void *dbdata,
|
|||
* remove the trailing newline.
|
||||
*/
|
||||
n = snprintf(buf, sizeof(buf), "\"%s", ctime(&now));
|
||||
if (n < 0)
|
||||
if (n <= 0) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
if (n >= sizeof(buf) || buf[n - 1] != '\n') {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
buf[n - 1] = '\"';
|
||||
result = dns_sdb_putrr(lookup, "txt", 1, buf);
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
} else if (strcmp(name, "clock") == 0) {
|
||||
result = dns_sdb_putrr(lookup, "cname", 1, "time");
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (ISC_R_FAILURE);
|
||||
}
|
||||
} else if (strcmp(name, "current") == 0) {
|
||||
result = dns_sdb_putrr(lookup, "dname", 1, "@");
|
||||
if (result != ISC_R_SUCCESS)
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (ISC_R_FAILURE);
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
return (ISC_R_NOTFOUND);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue