aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-08 09:07:50 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-08 09:07:50 +0100
commit9037787eaee5efb58fd46f326397193b16b161dd (patch)
treedfd0e7d93faf711ca7dcf8c7fe0abfb21082e3d3 /networking
parentef3817c6dcbf9270d36b48a0547e507221abce74 (diff)
downloadbusybox-w32-9037787eaee5efb58fd46f326397193b16b161dd.tar.gz
busybox-w32-9037787eaee5efb58fd46f326397193b16b161dd.tar.bz2
busybox-w32-9037787eaee5efb58fd46f326397193b16b161dd.zip
*: fix places where we were still using malloc/realloc
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/libiproute/ipaddress.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index c450c6a9f..03f5073fb 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -97,9 +97,8 @@ static void print_queuelen(char *name)
97static NOINLINE int print_linkinfo(const struct nlmsghdr *n) 97static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
98{ 98{
99 struct ifinfomsg *ifi = NLMSG_DATA(n); 99 struct ifinfomsg *ifi = NLMSG_DATA(n);
100 struct rtattr * tb[IFLA_MAX+1]; 100 struct rtattr *tb[IFLA_MAX+1];
101 int len = n->nlmsg_len; 101 int len = n->nlmsg_len;
102 unsigned m_flag = 0;
103 102
104 if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK) 103 if (n->nlmsg_type != RTM_NEWLINK && n->nlmsg_type != RTM_DELLINK)
105 return 0; 104 return 0;
@@ -130,22 +129,27 @@ static NOINLINE int print_linkinfo(const struct nlmsghdr *n)
130 printf("Deleted "); 129 printf("Deleted ");
131 130
132 printf("%d: %s", ifi->ifi_index, 131 printf("%d: %s", ifi->ifi_index,
133 tb[IFLA_IFNAME] ? (char*)RTA_DATA(tb[IFLA_IFNAME]) : "<nil>"); 132 /*tb[IFLA_IFNAME] ? (char*)RTA_DATA(tb[IFLA_IFNAME]) : "<nil>" - we checked tb[IFLA_IFNAME] above*/
134 133 (char*)RTA_DATA(tb[IFLA_IFNAME])
135 if (tb[IFLA_LINK]) { 134 );
136 SPRINT_BUF(b1); 135
137 int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]); 136 {
138 if (iflink == 0) 137 unsigned m_flag = 0;
139 printf("@NONE: "); 138 if (tb[IFLA_LINK]) {
140 else { 139 SPRINT_BUF(b1);
141 printf("@%s: ", ll_idx_n2a(iflink, b1)); 140 int iflink = *(int*)RTA_DATA(tb[IFLA_LINK]);
142 m_flag = ll_index_to_flags(iflink); 141 if (iflink == 0)
143 m_flag = !(m_flag & IFF_UP); 142 printf("@NONE: ");
143 else {
144 printf("@%s: ", ll_idx_n2a(iflink, b1));
145 m_flag = ll_index_to_flags(iflink);
146 m_flag = !(m_flag & IFF_UP);
147 }
148 } else {
149 printf(": ");
144 } 150 }
145 } else { 151 print_link_flags(ifi->ifi_flags, m_flag);
146 printf(": ");
147 } 152 }
148 print_link_flags(ifi->ifi_flags, m_flag);
149 153
150 if (tb[IFLA_MTU]) 154 if (tb[IFLA_MTU])
151 printf("mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU])); 155 printf("mtu %u ", *(int*)RTA_DATA(tb[IFLA_MTU]));
@@ -382,12 +386,10 @@ static int FAST_FUNC store_nlmsg(const struct sockaddr_nl *who, struct nlmsghdr
382 struct nlmsg_list *h; 386 struct nlmsg_list *h;
383 struct nlmsg_list **lp; 387 struct nlmsg_list **lp;
384 388
385 h = malloc(n->nlmsg_len+sizeof(void*)); 389 h = xzalloc(n->nlmsg_len + sizeof(void*));
386 if (h == NULL)
387 return -1;
388 390
389 memcpy(&h->h, n, n->nlmsg_len); 391 memcpy(&h->h, n, n->nlmsg_len);
390 h->next = NULL; 392 /*h->next = NULL; - xzalloc did it */
391 393
392 for (lp = linfo; *lp; lp = &(*lp)->next) 394 for (lp = linfo; *lp; lp = &(*lp)->next)
393 continue; 395 continue;