File tree Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Expand file tree Collapse file tree 1 file changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -874,15 +874,28 @@ void parse_trusted_mac_list(const char *ptr) {
874
874
config .trustedmaclist -> mac = safe_strdup (mac );
875
875
config .trustedmaclist -> next = NULL ;
876
876
} else {
877
- /* Advance to the last entry */
878
- p = config .trustedmaclist ;
879
- while (p -> next != NULL ) {
880
- p = p -> next ;
881
- }
882
- p -> next = safe_malloc (sizeof (t_trusted_mac ));
883
- p = p -> next ;
884
- p -> mac = safe_strdup (mac );
885
- p -> next = NULL ;
877
+ int skipmac ;
878
+ /* Advance to the last entry */
879
+ p = config .trustedmaclist ;
880
+ skipmac = 0 ;
881
+ /* Check before loop to handle case were mac is a duplicate
882
+ * of the first and only item in the list so far.
883
+ */
884
+ if (0 == strcmp (p -> mac , mac )) {
885
+ skipmac = 1 ;
886
+ }
887
+ while (p -> next != NULL ) {
888
+ if (0 == strcmp (p -> mac , mac )) {
889
+ skipmac = 1 ;
890
+ }
891
+ p = p -> next ;
892
+ }
893
+ if (!skipmac ) {
894
+ p -> next = safe_malloc (sizeof (t_trusted_mac ));
895
+ p = p -> next ;
896
+ p -> mac = safe_strdup (mac );
897
+ p -> next = NULL ;
898
+ }
886
899
}
887
900
}
888
901
}
You can’t perform that action at this time.
0 commit comments