ntp: check name and return status from NSR_AddSourceByName()

Return an error status when the name is not printable or contains a
space (don't bother with full hostname validation). If the name is an
address, return the same status as NSR_AddSource(). Otherwise, return a
"not resolved yet" status.
This commit is contained in:
Miroslav Lichvar
2019-12-12 11:58:18 +01:00
parent 2ae008bcee
commit 3763befd62
3 changed files with 22 additions and 6 deletions

View File

@@ -729,6 +729,8 @@ handle_add_source(NTP_Source_Type type, CMD_Request *rx_message, CMD_Reply *tx_m
tx_message->status = htons(STT_INVALIDAF);
break;
case NSR_NoSuchSource:
case NSR_InvalidName:
case NSR_UnresolvedName:
assert(0);
break;
}
@@ -755,6 +757,8 @@ handle_del_source(CMD_Request *rx_message, CMD_Reply *tx_message)
case NSR_TooManySources:
case NSR_AlreadyInUse:
case NSR_InvalidAF:
case NSR_InvalidName:
case NSR_UnresolvedName:
assert(0);
break;
}