Add checks for int parameters values
This commit is contained in:
		
							
								
								
									
										14
									
								
								gget.c
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								gget.c
									
									
									
									
									
								
							| @@ -515,7 +515,12 @@ int main(int argc, char** argv) | ||||
|     while ((opt = getopt(argc, argv, "hn:l:o:u:qm:")) != -1) { | ||||
|         switch (opt) { | ||||
|         case 'n': | ||||
|             nb_threads = atoi(optarg); | ||||
|             nb_threads = strtoul(optarg, &endptr, 0); | ||||
|             if (*endptr) | ||||
|             { | ||||
|                 usage(argv[0]); | ||||
|                 return 1; | ||||
|             } | ||||
|             if (nb_threads == 0) | ||||
|                 nb_threads = DEFAULT_NB_THREADS; | ||||
|             else if (nb_threads > MAX_NB_THREADS) | ||||
| @@ -525,7 +530,12 @@ int main(int argc, char** argv) | ||||
|             } | ||||
|             break; | ||||
|         case 'l': | ||||
|             max_speed = atoi(optarg); | ||||
|             max_speed = strtoul(optarg, &endptr, 0); | ||||
|             if (*endptr) | ||||
|             { | ||||
|                 usage(argv[0]); | ||||
|                 return 1; | ||||
|             } | ||||
|             break; | ||||
|         case 'm': | ||||
|             if (strlen(optarg) > 1) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user