Skip to content

Commit

Permalink
Stricter command line args validation to dhcp_release6.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Nechaev authored and simonkelley committed May 14, 2016
1 parent 88b09aa commit 45cb8dd
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions contrib/lease-tools/dhcp_release6.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,12 @@ int send_release_packet(const char* iface, struct dhcp6_packet* packet){


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;
Expand Down Expand Up @@ -392,7 +393,7 @@ int main(int argc, char * const argv[]) {
break;
case 'h':
usage(argv[0], stdout);
break;
return 0;
case '?':
usage(argv[0], stderr);
return -1;
Expand All @@ -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);
if (dry_run){
uint16_t i;
Expand Down

0 comments on commit 45cb8dd

Please sign in to comment.