diff --git a/hcxpcapngtool.c b/hcxpcapngtool.c index 5da9eb69d..c12fbe271 100644 --- a/hcxpcapngtool.c +++ b/hcxpcapngtool.c @@ -5647,9 +5647,20 @@ return; static bool processgpxfile(char *gpxinname) { static FILE *fh_gpxin; +static struct stat statinfo; +static int *gpxstart; + +if(stat(gpxinname, &statinfo) != 0) return false; +if(statinfo.st_size == 0) return false; +if((gpxstart = calloc(1, statinfo.st_size)) == NULL) return false; +if((fh_gpxin = fopen(gpxinname, "r")) == NULL) + { + free(gpxstart); + return false; + } -if((fh_gpxin = fopen(gpxinname, "r")) == NULL) return false; +free(gpxstart); fclose(fh_gpxin); return true; }