mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
- Fix unbound-control local_data and local_datas to print detailed
syntax errors.
This commit is contained in:
parent
e388ba2967
commit
9e712e8a0b
3 changed files with 33 additions and 6 deletions
|
|
@ -1304,10 +1304,35 @@ do_zones_remove(RES* ssl, struct local_zones* zones)
|
|||
(void)ssl_printf(ssl, "removed %d zones\n", num);
|
||||
}
|
||||
|
||||
/** check syntax of newly added RR */
|
||||
static int
|
||||
check_RR_syntax(RES* ssl, char* str, int line)
|
||||
{
|
||||
uint8_t rr[LDNS_RR_BUF_SIZE];
|
||||
size_t len = sizeof(rr), dname_len = 0;
|
||||
int s = sldns_str2wire_rr_buf(str, rr, &len, &dname_len, 3600,
|
||||
NULL, 0, NULL, 0);
|
||||
if(s != 0) {
|
||||
char linestr[32];
|
||||
if(line == 0)
|
||||
linestr[0]=0;
|
||||
else snprintf(linestr, sizeof(linestr), "line %d ", line);
|
||||
if(!ssl_printf(ssl, "error parsing local-data at %sposition %d '%s': %s\n",
|
||||
linestr, LDNS_WIREPARSE_OFFSET(s), str,
|
||||
sldns_get_errorstr_parse(s)))
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** Add new RR data */
|
||||
static int
|
||||
perform_data_add(RES* ssl, struct local_zones* zones, char* arg)
|
||||
perform_data_add(RES* ssl, struct local_zones* zones, char* arg, int line)
|
||||
{
|
||||
if(!check_RR_syntax(ssl, arg, line)) {
|
||||
return 0;
|
||||
}
|
||||
if(!local_zones_add_RR(zones, arg)) {
|
||||
ssl_printf(ssl,"error in syntax or out of memory, %s\n", arg);
|
||||
return 0;
|
||||
|
|
@ -1319,7 +1344,7 @@ perform_data_add(RES* ssl, struct local_zones* zones, char* arg)
|
|||
static void
|
||||
do_data_add(RES* ssl, struct local_zones* zones, char* arg)
|
||||
{
|
||||
if(!perform_data_add(ssl, zones, arg))
|
||||
if(!perform_data_add(ssl, zones, arg, 0))
|
||||
return;
|
||||
send_ok(ssl);
|
||||
}
|
||||
|
|
@ -1329,11 +1354,12 @@ static void
|
|||
do_datas_add(RES* ssl, struct local_zones* zones)
|
||||
{
|
||||
char buf[2048];
|
||||
int num = 0;
|
||||
int num = 0, line = 0;
|
||||
while(ssl_read_line(ssl, buf, sizeof(buf))) {
|
||||
if(buf[0] == 0x04 && buf[1] == 0)
|
||||
break; /* end of transmission */
|
||||
if(!perform_data_add(ssl, zones, buf)) {
|
||||
line++;
|
||||
if(!perform_data_add(ssl, zones, buf, line)) {
|
||||
if(!ssl_printf(ssl, "error for input line: %s\n", buf))
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
- Fix for #510: in depth, use ifdefs for windows api event calls.
|
||||
- Fix spelling in doc/unbound.doxygen comment.
|
||||
- Fix spelling in localzone.h comment.
|
||||
- Fix unbound-control local_data and local_datas to print detailed
|
||||
syntax errors.
|
||||
|
||||
6 July 2021: Wouter
|
||||
- iana portlist update.
|
||||
|
|
|
|||
|
|
@ -89,8 +89,7 @@ it. If the zone does not exist, the command succeeds.
|
|||
Add new local data, the given resource record. Like \fBlocal\-data\fR
|
||||
config statement, except for when no covering zone exists. In that case
|
||||
this remote control command creates a transparent zone with the same
|
||||
name as this record. This command is not good at returning detailed syntax
|
||||
errors.
|
||||
name as this record.
|
||||
.TP
|
||||
.B local_data_remove \fIname
|
||||
Remove all RR data from local name. If the name already has no items,
|
||||
|
|
|
|||
Loading…
Reference in a new issue