Deleted Added
full compact
dbus_dict_helpers.c (214501) dbus_dict_helpers.c (252190)
1/*
2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 *
1/*
2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
13 */
14
15#include "includes.h"
16#include <dbus/dbus.h>
17
18#include "common.h"
7 */
8
9#include "includes.h"
10#include <dbus/dbus.h>
11
12#include "common.h"
13#include "wpabuf.h"
19#include "dbus_dict_helpers.h"
20
21
22/**
23 * Start a dict in a dbus message. Should be paired with a call to
24 * wpa_dbus_dict_close_write().
25 *
26 * @param iter A valid dbus message iterator

--- 411 unchanged lines hidden (view full) ---

438 if (!value && (value_len != 0))
439 return FALSE;
440 return _wpa_dbus_add_dict_entry_byte_array(iter_dict, key, value,
441 value_len);
442}
443
444
445/**
14#include "dbus_dict_helpers.h"
15
16
17/**
18 * Start a dict in a dbus message. Should be paired with a call to
19 * wpa_dbus_dict_close_write().
20 *
21 * @param iter A valid dbus message iterator

--- 411 unchanged lines hidden (view full) ---

433 if (!value && (value_len != 0))
434 return FALSE;
435 return _wpa_dbus_add_dict_entry_byte_array(iter_dict, key, value,
436 value_len);
437}
438
439
440/**
446 * Begin a string array entry in the dict
441 * Begin an array entry in the dict
447 *
448 * @param iter_dict A valid DBusMessageIter returned from
449 * wpa_dbus_dict_open_write()
450 * @param key The key of the dict item
442 *
443 * @param iter_dict A valid DBusMessageIter returned from
444 * wpa_dbus_dict_open_write()
445 * @param key The key of the dict item
446 * @param type The type of the contained data
451 * @param iter_dict_entry A private DBusMessageIter provided by the caller to
452 * be passed to wpa_dbus_dict_end_string_array()
453 * @param iter_dict_val A private DBusMessageIter provided by the caller to
454 * be passed to wpa_dbus_dict_end_string_array()
455 * @param iter_array On return, the DBusMessageIter to be passed to
456 * wpa_dbus_dict_string_array_add_element()
457 * @return TRUE on success, FALSE on failure
458 *
459 */
447 * @param iter_dict_entry A private DBusMessageIter provided by the caller to
448 * be passed to wpa_dbus_dict_end_string_array()
449 * @param iter_dict_val A private DBusMessageIter provided by the caller to
450 * be passed to wpa_dbus_dict_end_string_array()
451 * @param iter_array On return, the DBusMessageIter to be passed to
452 * wpa_dbus_dict_string_array_add_element()
453 * @return TRUE on success, FALSE on failure
454 *
455 */
460dbus_bool_t wpa_dbus_dict_begin_string_array(DBusMessageIter *iter_dict,
461 const char *key,
462 DBusMessageIter *iter_dict_entry,
463 DBusMessageIter *iter_dict_val,
464 DBusMessageIter *iter_array)
456dbus_bool_t wpa_dbus_dict_begin_array(DBusMessageIter *iter_dict,
457 const char *key, const char *type,
458 DBusMessageIter *iter_dict_entry,
459 DBusMessageIter *iter_dict_val,
460 DBusMessageIter *iter_array)
465{
461{
462 char array_type[10];
463 int err;
464
465 err = os_snprintf(array_type, sizeof(array_type),
466 DBUS_TYPE_ARRAY_AS_STRING "%s",
467 type);
468 if (err < 0 || err > (int) sizeof(array_type))
469 return FALSE;
470
466 if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
467 return FALSE;
468
469 if (!_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry,
470 key, DBUS_TYPE_ARRAY))
471 return FALSE;
472
473 if (!dbus_message_iter_open_container(iter_dict_entry,
474 DBUS_TYPE_VARIANT,
471 if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
472 return FALSE;
473
474 if (!_wpa_dbus_add_dict_entry_start(iter_dict, iter_dict_entry,
475 key, DBUS_TYPE_ARRAY))
476 return FALSE;
477
478 if (!dbus_message_iter_open_container(iter_dict_entry,
479 DBUS_TYPE_VARIANT,
475 DBUS_TYPE_ARRAY_AS_STRING
476 DBUS_TYPE_STRING_AS_STRING,
480 array_type,
477 iter_dict_val))
478 return FALSE;
479
480 if (!dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY,
481 iter_dict_val))
482 return FALSE;
483
484 if (!dbus_message_iter_open_container(iter_dict_val, DBUS_TYPE_ARRAY,
481 DBUS_TYPE_BYTE_AS_STRING,
482 iter_array))
485 type, iter_array))
483 return FALSE;
484
485 return TRUE;
486}
487
488
486 return FALSE;
487
488 return TRUE;
489}
490
491
492dbus_bool_t wpa_dbus_dict_begin_string_array(DBusMessageIter *iter_dict,
493 const char *key,
494 DBusMessageIter *iter_dict_entry,
495 DBusMessageIter *iter_dict_val,
496 DBusMessageIter *iter_array)
497{
498 return wpa_dbus_dict_begin_array(
499 iter_dict, key,
500 DBUS_TYPE_STRING_AS_STRING,
501 iter_dict_entry, iter_dict_val, iter_array);
502}
503
504
489/**
490 * Add a single string element to a string array dict entry
491 *
492 * @param iter_array A valid DBusMessageIter returned from
493 * wpa_dbus_dict_begin_string_array()'s
494 * iter_array parameter
495 * @param elem The string element to be added to the dict entry's string array
496 * @return TRUE on success, FALSE on failure

--- 6 unchanged lines hidden (view full) ---

503 return FALSE;
504
505 return dbus_message_iter_append_basic(iter_array, DBUS_TYPE_STRING,
506 &elem);
507}
508
509
510/**
505/**
506 * Add a single string element to a string array dict entry
507 *
508 * @param iter_array A valid DBusMessageIter returned from
509 * wpa_dbus_dict_begin_string_array()'s
510 * iter_array parameter
511 * @param elem The string element to be added to the dict entry's string array
512 * @return TRUE on success, FALSE on failure

--- 6 unchanged lines hidden (view full) ---

519 return FALSE;
520
521 return dbus_message_iter_append_basic(iter_array, DBUS_TYPE_STRING,
522 &elem);
523}
524
525
526/**
511 * End a string array dict entry
527 * Add a single byte array element to a string array dict entry
512 *
528 *
529 * @param iter_array A valid DBusMessageIter returned from
530 * wpa_dbus_dict_begin_array()'s iter_array
531 * parameter -- note that wpa_dbus_dict_begin_array()
532 * must have been called with "ay" as the type
533 * @param value The data to be added to the dict entry's array
534 * @param value_len The length of the data
535 * @return TRUE on success, FALSE on failure
536 *
537 */
538dbus_bool_t wpa_dbus_dict_bin_array_add_element(DBusMessageIter *iter_array,
539 const u8 *value,
540 size_t value_len)
541{
542 DBusMessageIter iter_bytes;
543 size_t i;
544
545 if (!iter_array || !value)
546 return FALSE;
547
548 if (!dbus_message_iter_open_container(iter_array, DBUS_TYPE_ARRAY,
549 DBUS_TYPE_BYTE_AS_STRING,
550 &iter_bytes))
551 return FALSE;
552
553 for (i = 0; i < value_len; i++) {
554 if (!dbus_message_iter_append_basic(&iter_bytes,
555 DBUS_TYPE_BYTE,
556 &(value[i])))
557 return FALSE;
558 }
559
560 if (!dbus_message_iter_close_container(iter_array, &iter_bytes))
561 return FALSE;
562
563 return TRUE;
564}
565
566
567/**
568 * End an array dict entry
569 *
513 * @param iter_dict A valid DBusMessageIter returned from
514 * wpa_dbus_dict_open_write()
515 * @param iter_dict_entry A private DBusMessageIter returned from
570 * @param iter_dict A valid DBusMessageIter returned from
571 * wpa_dbus_dict_open_write()
572 * @param iter_dict_entry A private DBusMessageIter returned from
516 * wpa_dbus_dict_end_string_array()
573 * wpa_dbus_dict_begin_string_array() or
574 * wpa_dbus_dict_begin_array()
517 * @param iter_dict_val A private DBusMessageIter returned from
575 * @param iter_dict_val A private DBusMessageIter returned from
518 * wpa_dbus_dict_end_string_array()
576 * wpa_dbus_dict_begin_string_array() or
577 * wpa_dbus_dict_begin_array()
519 * @param iter_array A DBusMessageIter returned from
578 * @param iter_array A DBusMessageIter returned from
520 * wpa_dbus_dict_end_string_array()
579 * wpa_dbus_dict_begin_string_array() or
580 * wpa_dbus_dict_begin_array()
521 * @return TRUE on success, FALSE on failure
522 *
523 */
581 * @return TRUE on success, FALSE on failure
582 *
583 */
524dbus_bool_t wpa_dbus_dict_end_string_array(DBusMessageIter *iter_dict,
525 DBusMessageIter *iter_dict_entry,
526 DBusMessageIter *iter_dict_val,
527 DBusMessageIter *iter_array)
584dbus_bool_t wpa_dbus_dict_end_array(DBusMessageIter *iter_dict,
585 DBusMessageIter *iter_dict_entry,
586 DBusMessageIter *iter_dict_val,
587 DBusMessageIter *iter_array)
528{
529 if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
530 return FALSE;
531
532 if (!dbus_message_iter_close_container(iter_dict_val, iter_array))
533 return FALSE;
534
535 if (!_wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,

--- 42 unchanged lines hidden (view full) ---

578 if (!wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry,
579 &iter_dict_val, &iter_array))
580 return FALSE;
581
582 return TRUE;
583}
584
585
588{
589 if (!iter_dict || !iter_dict_entry || !iter_dict_val || !iter_array)
590 return FALSE;
591
592 if (!dbus_message_iter_close_container(iter_dict_val, iter_array))
593 return FALSE;
594
595 if (!_wpa_dbus_add_dict_entry_end(iter_dict, iter_dict_entry,

--- 42 unchanged lines hidden (view full) ---

638 if (!wpa_dbus_dict_end_string_array(iter_dict, &iter_dict_entry,
639 &iter_dict_val, &iter_array))
640 return FALSE;
641
642 return TRUE;
643}
644
645
646/**
647 * Convenience function to add an wpabuf binary array to the dict.
648 *
649 * @param iter_dict A valid DBusMessageIter returned from
650 * wpa_dbus_dict_open_write()
651 * @param key The key of the dict item
652 * @param items The array of wpabuf structures
653 * @param num_items The number of strings in the array
654 * @return TRUE on success, FALSE on failure
655 *
656 */
657dbus_bool_t wpa_dbus_dict_append_wpabuf_array(DBusMessageIter *iter_dict,
658 const char *key,
659 const struct wpabuf **items,
660 const dbus_uint32_t num_items)
661{
662 DBusMessageIter iter_dict_entry, iter_dict_val, iter_array;
663 dbus_uint32_t i;
664
665 if (!key)
666 return FALSE;
667 if (!items && (num_items != 0))
668 return FALSE;
669
670 if (!wpa_dbus_dict_begin_array(iter_dict, key,
671 DBUS_TYPE_ARRAY_AS_STRING
672 DBUS_TYPE_BYTE_AS_STRING,
673 &iter_dict_entry, &iter_dict_val,
674 &iter_array))
675 return FALSE;
676
677 for (i = 0; i < num_items; i++) {
678 if (!wpa_dbus_dict_bin_array_add_element(&iter_array,
679 wpabuf_head(items[i]),
680 wpabuf_len(items[i])))
681 return FALSE;
682 }
683
684 if (!wpa_dbus_dict_end_array(iter_dict, &iter_dict_entry,
685 &iter_dict_val, &iter_array))
686 return FALSE;
687
688 return TRUE;
689}
690
691
586/*****************************************************/
587/* Stuff for reading dicts */
588/*****************************************************/
589
590/**
591 * Start reading from a dbus dict.
592 *
593 * @param iter A valid DBusMessageIter pointing to the start of the dict
594 * @param iter_dict (out) A DBusMessageIter to be passed to
595 * wpa_dbus_dict_read_next_entry()
692/*****************************************************/
693/* Stuff for reading dicts */
694/*****************************************************/
695
696/**
697 * Start reading from a dbus dict.
698 *
699 * @param iter A valid DBusMessageIter pointing to the start of the dict
700 * @param iter_dict (out) A DBusMessageIter to be passed to
701 * wpa_dbus_dict_read_next_entry()
702 * @error on failure a descriptive error
596 * @return TRUE on success, FALSE on failure
597 *
598 */
599dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter,
703 * @return TRUE on success, FALSE on failure
704 *
705 */
706dbus_bool_t wpa_dbus_dict_open_read(DBusMessageIter *iter,
600 DBusMessageIter *iter_dict)
707 DBusMessageIter *iter_dict,
708 DBusError *error)
601{
709{
602 if (!iter || !iter_dict)
710 if (!iter || !iter_dict) {
711 dbus_set_error_const(error, DBUS_ERROR_FAILED,
712 "[internal] missing message iterators");
603 return FALSE;
713 return FALSE;
714 }
604
605 if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY ||
715
716 if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY ||
606 dbus_message_iter_get_element_type(iter) != DBUS_TYPE_DICT_ENTRY)
717 dbus_message_iter_get_element_type(iter) != DBUS_TYPE_DICT_ENTRY) {
718 dbus_set_error_const(error, DBUS_ERROR_INVALID_ARGS,
719 "unexpected message argument types");
607 return FALSE;
720 return FALSE;
721 }
608
609 dbus_message_iter_recurse(iter, iter_dict);
610 return TRUE;
611}
612
613
614#define BYTE_ARRAY_CHUNK_SIZE 34
615#define BYTE_ARRAY_ITEM_SIZE (sizeof(char))
616
617static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
722
723 dbus_message_iter_recurse(iter, iter_dict);
724 return TRUE;
725}
726
727
728#define BYTE_ARRAY_CHUNK_SIZE 34
729#define BYTE_ARRAY_ITEM_SIZE (sizeof(char))
730
731static dbus_bool_t _wpa_dbus_dict_entry_get_byte_array(
618 DBusMessageIter *iter, int array_type,
619 struct wpa_dbus_dict_entry *entry)
732 DBusMessageIter *iter, struct wpa_dbus_dict_entry *entry)
620{
621 dbus_uint32_t count = 0;
622 dbus_bool_t success = FALSE;
733{
734 dbus_uint32_t count = 0;
735 dbus_bool_t success = FALSE;
623 char *buffer, *nbuffer;;
736 char *buffer, *nbuffer;
624
625 entry->bytearray_value = NULL;
626 entry->array_type = DBUS_TYPE_BYTE;
627
737
738 entry->bytearray_value = NULL;
739 entry->array_type = DBUS_TYPE_BYTE;
740
628 buffer = os_zalloc(BYTE_ARRAY_ITEM_SIZE * BYTE_ARRAY_CHUNK_SIZE);
741 buffer = os_calloc(BYTE_ARRAY_CHUNK_SIZE, BYTE_ARRAY_ITEM_SIZE);
629 if (!buffer)
630 return FALSE;
631
632 entry->bytearray_value = buffer;
633 entry->array_len = 0;
634 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) {
635 char byte;
636
637 if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
742 if (!buffer)
743 return FALSE;
744
745 entry->bytearray_value = buffer;
746 entry->array_len = 0;
747 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_BYTE) {
748 char byte;
749
750 if ((count % BYTE_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
638 nbuffer = os_realloc(buffer, BYTE_ARRAY_ITEM_SIZE *
639 (count + BYTE_ARRAY_CHUNK_SIZE));
751 nbuffer = os_realloc_array(
752 buffer, count + BYTE_ARRAY_CHUNK_SIZE,
753 BYTE_ARRAY_ITEM_SIZE);
640 if (nbuffer == NULL) {
641 os_free(buffer);
642 wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
643 "entry_get_byte_array out of "
644 "memory trying to retrieve the "
645 "string array");
646 goto done;
647 }

--- 29 unchanged lines hidden (view full) ---

677{
678 dbus_uint32_t count = 0;
679 dbus_bool_t success = FALSE;
680 char **buffer, **nbuffer;
681
682 entry->strarray_value = NULL;
683 entry->array_type = DBUS_TYPE_STRING;
684
754 if (nbuffer == NULL) {
755 os_free(buffer);
756 wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
757 "entry_get_byte_array out of "
758 "memory trying to retrieve the "
759 "string array");
760 goto done;
761 }

--- 29 unchanged lines hidden (view full) ---

791{
792 dbus_uint32_t count = 0;
793 dbus_bool_t success = FALSE;
794 char **buffer, **nbuffer;
795
796 entry->strarray_value = NULL;
797 entry->array_type = DBUS_TYPE_STRING;
798
685 buffer = os_zalloc(STR_ARRAY_ITEM_SIZE * STR_ARRAY_CHUNK_SIZE);
799 buffer = os_calloc(STR_ARRAY_CHUNK_SIZE, STR_ARRAY_ITEM_SIZE);
686 if (buffer == NULL)
687 return FALSE;
688
689 entry->strarray_value = buffer;
690 entry->array_len = 0;
691 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) {
692 const char *value;
693 char *str;
694
695 if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
800 if (buffer == NULL)
801 return FALSE;
802
803 entry->strarray_value = buffer;
804 entry->array_len = 0;
805 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRING) {
806 const char *value;
807 char *str;
808
809 if ((count % STR_ARRAY_CHUNK_SIZE) == 0 && count != 0) {
696 nbuffer = os_realloc(buffer, STR_ARRAY_ITEM_SIZE *
697 (count + STR_ARRAY_CHUNK_SIZE));
810 nbuffer = os_realloc_array(
811 buffer, count + STR_ARRAY_CHUNK_SIZE,
812 STR_ARRAY_ITEM_SIZE);
698 if (nbuffer == NULL) {
699 os_free(buffer);
700 wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
701 "entry_get_string_array out of "
702 "memory trying to retrieve the "
703 "string array");
704 goto done;
705 }

--- 22 unchanged lines hidden (view full) ---

728
729 success = TRUE;
730
731done:
732 return success;
733}
734
735
813 if (nbuffer == NULL) {
814 os_free(buffer);
815 wpa_printf(MSG_ERROR, "dbus: _wpa_dbus_dict_"
816 "entry_get_string_array out of "
817 "memory trying to retrieve the "
818 "string array");
819 goto done;
820 }

--- 22 unchanged lines hidden (view full) ---

843
844 success = TRUE;
845
846done:
847 return success;
848}
849
850
851#define BIN_ARRAY_CHUNK_SIZE 10
852#define BIN_ARRAY_ITEM_SIZE (sizeof(struct wpabuf *))
853
854static dbus_bool_t _wpa_dbus_dict_entry_get_binarray(
855 DBusMessageIter *iter, struct wpa_dbus_dict_entry *entry)
856{
857 struct wpa_dbus_dict_entry tmpentry;
858 size_t buflen = 0;
859 int i;
860
861 if (dbus_message_iter_get_element_type(iter) != DBUS_TYPE_BYTE)
862 return FALSE;
863
864 entry->array_type = WPAS_DBUS_TYPE_BINARRAY;
865 entry->array_len = 0;
866 entry->binarray_value = NULL;
867
868 while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_ARRAY) {
869 DBusMessageIter iter_array;
870
871 if (entry->array_len == buflen) {
872 struct wpabuf **newbuf;
873
874 buflen += BIN_ARRAY_CHUNK_SIZE;
875
876 newbuf = os_realloc_array(entry->binarray_value,
877 buflen, BIN_ARRAY_ITEM_SIZE);
878 if (!newbuf)
879 goto cleanup;
880 entry->binarray_value = newbuf;
881 }
882
883 dbus_message_iter_recurse(iter, &iter_array);
884 if (_wpa_dbus_dict_entry_get_byte_array(&iter_array, &tmpentry)
885 == FALSE)
886 goto cleanup;
887
888 entry->binarray_value[entry->array_len] =
889 wpabuf_alloc_ext_data((u8 *) tmpentry.bytearray_value,
890 tmpentry.array_len);
891 if (entry->binarray_value[entry->array_len] == NULL) {
892 wpa_dbus_dict_entry_clear(&tmpentry);
893 goto cleanup;
894 }
895 entry->array_len++;
896 dbus_message_iter_next(iter);
897 }
898
899 return TRUE;
900
901 cleanup:
902 for (i = 0; i < (int) entry->array_len; i++)
903 wpabuf_free(entry->binarray_value[i]);
904 os_free(entry->binarray_value);
905 entry->array_len = 0;
906 entry->binarray_value = NULL;
907 return FALSE;
908}
909
910
736static dbus_bool_t _wpa_dbus_dict_entry_get_array(
737 DBusMessageIter *iter_dict_val, struct wpa_dbus_dict_entry *entry)
738{
739 int array_type = dbus_message_iter_get_element_type(iter_dict_val);
740 dbus_bool_t success = FALSE;
741 DBusMessageIter iter_array;
742
743 if (!entry)
744 return FALSE;
745
746 dbus_message_iter_recurse(iter_dict_val, &iter_array);
747
748 switch (array_type) {
749 case DBUS_TYPE_BYTE:
750 success = _wpa_dbus_dict_entry_get_byte_array(&iter_array,
911static dbus_bool_t _wpa_dbus_dict_entry_get_array(
912 DBusMessageIter *iter_dict_val, struct wpa_dbus_dict_entry *entry)
913{
914 int array_type = dbus_message_iter_get_element_type(iter_dict_val);
915 dbus_bool_t success = FALSE;
916 DBusMessageIter iter_array;
917
918 if (!entry)
919 return FALSE;
920
921 dbus_message_iter_recurse(iter_dict_val, &iter_array);
922
923 switch (array_type) {
924 case DBUS_TYPE_BYTE:
925 success = _wpa_dbus_dict_entry_get_byte_array(&iter_array,
751 array_type,
752 entry);
753 break;
754 case DBUS_TYPE_STRING:
755 success = _wpa_dbus_dict_entry_get_string_array(&iter_array,
756 array_type,
757 entry);
758 break;
926 entry);
927 break;
928 case DBUS_TYPE_STRING:
929 success = _wpa_dbus_dict_entry_get_string_array(&iter_array,
930 array_type,
931 entry);
932 break;
933 case DBUS_TYPE_ARRAY:
934 success = _wpa_dbus_dict_entry_get_binarray(&iter_array, entry);
759 default:
760 break;
761 }
762
763 return success;
764}
765
766

--- 143 unchanged lines hidden (view full) ---

910 case DBUS_TYPE_BYTE:
911 os_free(entry->bytearray_value);
912 break;
913 case DBUS_TYPE_STRING:
914 for (i = 0; i < entry->array_len; i++)
915 os_free(entry->strarray_value[i]);
916 os_free(entry->strarray_value);
917 break;
935 default:
936 break;
937 }
938
939 return success;
940}
941
942

--- 143 unchanged lines hidden (view full) ---

1086 case DBUS_TYPE_BYTE:
1087 os_free(entry->bytearray_value);
1088 break;
1089 case DBUS_TYPE_STRING:
1090 for (i = 0; i < entry->array_len; i++)
1091 os_free(entry->strarray_value[i]);
1092 os_free(entry->strarray_value);
1093 break;
1094 case WPAS_DBUS_TYPE_BINARRAY:
1095 for (i = 0; i < entry->array_len; i++)
1096 wpabuf_free(entry->binarray_value[i]);
1097 os_free(entry->binarray_value);
1098 break;
918 }
919 break;
920 }
921
1099 }
1100 break;
1101 }
1102
922 memset(entry, 0, sizeof(struct wpa_dbus_dict_entry));
1103 os_memset(entry, 0, sizeof(struct wpa_dbus_dict_entry));
923}
1104}