From 8e592d8957f74be65b8f5a563e7f25f8dce956bf Mon Sep 17 00:00:00 2001
From: Vadim Vetrov <vetrovvd@gmail.com>
Date: Sat, 10 Aug 2024 00:40:31 +0300
Subject: [PATCH] Fix segfault on unrecognized option

---
 youtubeUnblock.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/youtubeUnblock.c b/youtubeUnblock.c
index 9342027..21ad485 100644
--- a/youtubeUnblock.c
+++ b/youtubeUnblock.c
@@ -65,6 +65,11 @@ struct config_t config = {
 static long parse_numeric_option(const char* value) {
 	errno = 0;
 
+	if (*value == '\0') {
+		errno = EINVAL;
+		return 0;
+	}
+
 	char* end;
 	long result = strtol(value, &end, 10);
 	if (*end != '\0') {
@@ -208,7 +213,6 @@ static int parse_args(int argc, char *argv[]) {
 				config.fake_sni_ttl = num;
 				break;
 			default:
-				printf("Invalid option %s\n", long_opt[optIdx].name);
 				goto error;
 		}
 	}