mirror of
https://github.com/ValdikSS/GoodbyeDPI.git
synced 2024-11-21 17:45:24 +01:00
Allocate (argc + 1) for the service arguments, with calloc
It was assumed that getopt checks argc count and does not require null-terminated argv pointer to determine argv end for optional parameter. That is wrong. Add null-terminated latest argv. Fixes #246
This commit is contained in:
parent
1cfd2b1b9f
commit
8deacbc438
@ -30,7 +30,7 @@ int service_register(int argc, char *argv[])
|
||||
*/
|
||||
if (!service_argc && !service_argv) {
|
||||
service_argc = argc;
|
||||
service_argv = malloc(sizeof(void*) * (size_t)argc);
|
||||
service_argv = calloc(sizeof(void*), (size_t)(argc + 1));
|
||||
for (i = 0; i < argc; i++) {
|
||||
service_argv[i] = strdup(argv[i]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user