Skip to content

Commit 273f744

Browse files
committed
Merge branch 'sanitize' of github.com:amboar/mctp
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
2 parents b287a76 + c62e013 commit 273f744

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

.github/workflows/pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
run: pip install --user -r tests/requirements.txt
1919

2020
- name: Configure mctp build
21-
run: meson setup build -Db_sanitize=address
21+
run: meson setup build -Db_sanitize=address,undefined
2222

2323
- name: Build mctp
2424
run: meson compile -C build
@@ -58,7 +58,7 @@ jobs:
5858
run: pip install --user -r tests/requirements.txt
5959

6060
- name: Configure mctp build
61-
run: meson setup build -Db_sanitize=address
61+
run: meson setup build -Db_sanitize=address,undefined
6262

6363
- name: Build mctp
6464
run: meson compile -C build

src/mctp-netlink.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -952,13 +952,17 @@ static void sort_linkmap(mctp_nl *nl)
952952
{
953953
size_t i;
954954

955-
qsort(nl->linkmap, nl->linkmap_count, sizeof(*nl->linkmap),
956-
cmp_ifindex);
955+
if (nl->linkmap) {
956+
qsort(nl->linkmap, nl->linkmap_count, sizeof(*nl->linkmap),
957+
cmp_ifindex);
958+
}
957959

958960
for (i = 0; i < nl->linkmap_count; i++) {
959961
struct linkmap_entry *entry = &nl->linkmap[i];
960-
qsort(entry->local_eids, entry->num_local, sizeof(mctp_eid_t),
961-
cmp_eid);
962+
if (entry->local_eids) {
963+
qsort(entry->local_eids, entry->num_local,
964+
sizeof(mctp_eid_t), cmp_eid);
965+
}
962966
}
963967
}
964968

@@ -1090,11 +1094,12 @@ mctp_eid_t *mctp_nl_addrs_byindex(const mctp_nl *nl, int index, size_t *ret_num)
10901094
mctp_eid_t *ret;
10911095

10921096
*ret_num = 0;
1093-
if (!entry)
1097+
if (!entry || entry->num_local == 0)
10941098
return NULL;
10951099
ret = malloc(entry->num_local);
10961100
if (!ret)
10971101
return NULL;
1102+
assert(entry->local_eids);
10981103
memcpy(ret, entry->local_eids, entry->num_local);
10991104
*ret_num = entry->num_local;
11001105
return ret;

0 commit comments

Comments
 (0)