Stricter command line args validation to dhcp_release6.
diff --git a/contrib/lease-tools/dhcp_release6.c b/contrib/lease-tools/dhcp_release6.c
index 74fb26a..00ff115 100644
--- a/contrib/lease-tools/dhcp_release6.c
+++ b/contrib/lease-tools/dhcp_release6.c
@@ -350,11 +350,12 @@
int main(int argc, char * const argv[]) {
- const char* iface = "";
- const char* ip = "";
- const char* client_id = "";
- const char* server_id = "";
- const char* iaid = "";
+ const char* UNINITIALIZED = "";
+ const char* iface = UNINITIALIZED;
+ const char* ip = UNINITIALIZED;
+ const char* client_id = UNINITIALIZED;
+ const char* server_id = UNINITIALIZED;
+ const char* iaid = UNINITIALIZED;
int dry_run = 0;
while (1) {
int option_index = 0;
@@ -392,7 +393,7 @@
break;
case 'h':
usage(argv[0], stdout);
- break;
+ return 0;
case '?':
usage(argv[0], stderr);
return -1;
@@ -402,6 +403,34 @@
}
}
+ 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);
if (dry_run){
uint16_t i;