utils

small programs, scripts and utils
git clone https://git.e1e0.net/utils.git
Log | Files | Refs

commit b26f781d1ae79ebbaf5168f990003d0f5529377b
parent e29633acd501496c3a30b5b2298ea66a605d2255
Author: Paco Esteban <paco@e1e0.net>
Date:   Sun, 14 Feb 2021 23:36:47 +0100

geoloc: fix segfault

Diffstat:
Mgeoloc/geoloc.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/geoloc/geoloc.c b/geoloc/geoloc.c @@ -28,6 +28,7 @@ #define BASE_URL "https://ipapi.co" #define JSON_ENDPOINT "json" +#define IN6ADDRSZ 16 const char *version = "v0.2.0"; @@ -171,8 +172,8 @@ print_data(void *json_data) { int main(int argc, char *argv[]) { - int ch, f_help = 0, f_version = 0, is_v4 = 0, is_v6 = 0; - void *inet_dst; // we do not actually use this. Only to check valid ip + int ch, f_version = 0, is_v4 = 0, is_v6 = 0; + char inet_dst[IN6ADDRSZ]; // we do not actually use this. Only to check valid ip char *url = NULL; @@ -200,8 +201,8 @@ main(int argc, char *argv[]) } // validate ip input - is_v4 = inet_pton(AF_INET, argv[0], inet_dst); - is_v6 = inet_pton(AF_INET6, argv[0], inet_dst); + is_v4 = inet_pton(AF_INET, argv[0], (void *)inet_dst); + is_v6 = inet_pton(AF_INET6, argv[0], (void *)inet_dst); if ((is_v4 != 1) && (is_v6 != 1)) err(1, "invalid IP");