@@ -301,6 +301,9 @@ parse_auth_server(FILE *file, const char *filename, int *linenum)
301
301
302
302
switch (opcode ) {
303
303
case oAuthServHostname :
304
+ /* Coverity rightfully pointed out we could have duplicates here. */
305
+ if (NULL != host )
306
+ free (host );
304
307
host = safe_strdup (p2 );
305
308
break ;
306
309
case oAuthServPath :
@@ -351,8 +354,15 @@ parse_auth_server(FILE *file, const char *filename, int *linenum)
351
354
}
352
355
353
356
/* only proceed if we have an host and a path */
354
- if (host == NULL )
357
+ if (host == NULL ) {
358
+ free (path );
359
+ free (authscriptpathfragment );
360
+ free (pingscriptpathfragment );
361
+ free (msgscriptpathfragment );
362
+ free (portalscriptpathfragment );
363
+ free (loginscriptpathfragment );
355
364
return ;
365
+ }
356
366
357
367
debug (LOG_DEBUG , "Adding %s:%d (SSL: %d) %s to the auth server list" ,
358
368
host , http_port , ssl_port , path );
@@ -850,6 +860,8 @@ void parse_trusted_mac_list(const char *ptr) {
850
860
/* check for valid format */
851
861
if (!check_mac_format (possiblemac )) {
852
862
debug (LOG_ERR , "[%s] not a valid MAC address to trust. See option TrustedMACList in wifidog.conf for correct this mistake." , possiblemac );
863
+ free (ptrcopy );
864
+ free (mac );
853
865
return ;
854
866
} else {
855
867
if (sscanf (possiblemac , " %17[A-Fa-f0-9:]" , mac ) == 1 ) {
@@ -864,10 +876,10 @@ void parse_trusted_mac_list(const char *ptr) {
864
876
} else {
865
877
/* Advance to the last entry */
866
878
for (p = config .trustedmaclist ; p -> next != NULL ; p = p -> next );
867
- p -> next = safe_malloc (sizeof (t_trusted_mac ));
868
- p = p -> next ;
869
- p -> mac = safe_strdup (mac );
870
- p -> next = NULL ;
879
+ p -> next = safe_malloc (sizeof (t_trusted_mac ));
880
+ p = p -> next ;
881
+ p -> mac = safe_strdup (mac );
882
+ p -> next = NULL ;
871
883
}
872
884
}
873
885
}
0 commit comments