Commit 45cb8dd9 authored by Sergey Nechaev's avatar Sergey Nechaev Committed by Simon Kelley

Stricter command line args validation to dhcp_release6.

parent 88b09aad
...@@ -350,11 +350,12 @@ int send_release_packet(const char* iface, struct dhcp6_packet* packet){ ...@@ -350,11 +350,12 @@ int send_release_packet(const char* iface, struct dhcp6_packet* packet){
int main(int argc, char * const argv[]) { int main(int argc, char * const argv[]) {
const char* iface = ""; const char* UNINITIALIZED = "";
const char* ip = ""; const char* iface = UNINITIALIZED;
const char* client_id = ""; const char* ip = UNINITIALIZED;
const char* server_id = ""; const char* client_id = UNINITIALIZED;
const char* iaid = ""; const char* server_id = UNINITIALIZED;
const char* iaid = UNINITIALIZED;
int dry_run = 0; int dry_run = 0;
while (1) { while (1) {
int option_index = 0; int option_index = 0;
...@@ -392,7 +393,7 @@ int main(int argc, char * const argv[]) { ...@@ -392,7 +393,7 @@ int main(int argc, char * const argv[]) {
break; break;
case 'h': case 'h':
usage(argv[0], stdout); usage(argv[0], stdout);
break; return 0;
case '?': case '?':
usage(argv[0], stderr); usage(argv[0], stderr);
return -1; return -1;
...@@ -402,6 +403,34 @@ int main(int argc, char * const argv[]) { ...@@ -402,6 +403,34 @@ int main(int argc, char * const argv[]) {
} }
} }
if (iaid == UNINITIALIZED){
fprintf(stderr, "Missing required iaid parameter\n");
usage(argv[0], stderr);
return -1;
}
if (server_id == UNINITIALIZED){
fprintf(stderr, "Missing required server-id parameter\n");
usage(argv[0], stderr);
return -1;
}
if (client_id == UNINITIALIZED){
fprintf(stderr, "Missing required client-id parameter\n");
usage(argv[0], stderr);
return -1;
}
if (ip == UNINITIALIZED){
fprintf(stderr, "Missing required ip parameter\n");
usage(argv[0], stderr);
return -1;
}
if (iface == UNINITIALIZED){
fprintf(stderr, "Missing required iface parameter\n");
usage(argv[0], stderr);
return -1;
}
struct dhcp6_packet packet = create_release_packet(iaid, ip, client_id, server_id); struct dhcp6_packet packet = create_release_packet(iaid, ip, client_id, server_id);
if (dry_run){ if (dry_run){
uint16_t i; uint16_t i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment