From: Michael Olbrich <m.olbrich@pengutronix.de>
To: ptxdist@pengutronix.de
Subject: Re: [ptxdist] [PATCH v2] lowpan_tools: add patch to avoid crashing
Date: Mon, 4 Mar 2013 17:40:40 +0100 [thread overview]
Message-ID: <20130304164040.GV5360@pengutronix.de> (raw)
In-Reply-To: <1362072012-12477-1-git-send-email-alex.aring@gmail.com>
On Thu, Feb 28, 2013 at 06:20:12PM +0100, Alexander Aring wrote:
> Add a non-mainlined lowpan_tools patch to avoid crashing
> in izcoordinator.
>
tnx, applied
Michael
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
> .../0001-Avoid-crashing-in-izcoordinator.patch | 139 +++++++++++++++++++++
> patches/lowpan-tools-0.3/series | 1 +
> 2 files changed, 140 insertions(+)
> create mode 100644 patches/lowpan-tools-0.3/0001-Avoid-crashing-in-izcoordinator.patch
> create mode 100644 patches/lowpan-tools-0.3/series
>
> diff --git a/patches/lowpan-tools-0.3/0001-Avoid-crashing-in-izcoordinator.patch b/patches/lowpan-tools-0.3/0001-Avoid-crashing-in-izcoordinator.patch
> new file mode 100644
> index 0000000..1b44f55
> --- /dev/null
> +++ b/patches/lowpan-tools-0.3/0001-Avoid-crashing-in-izcoordinator.patch
> @@ -0,0 +1,139 @@
> +From: Alexander Aring <alex.aring@gmail.com>
> +Date: Thu, 28 Feb 2013 13:17:08 +0100
> +Subject: [PATCH] Avoid crashing in izcoordinator.
> +
> +This patch fixes some logging issues in lowpan-tools to avoid crashing
> +of izcoordinator.
> +
> +Posted on linux-zigbee-devel mailinglist from Tom Carroll:
> +http://www.mail-archive.com/linux-zigbee-devel@lists.sourceforge.net/msg01224.html
> +
> +Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> +---
> + lib/logging.c | 6 +++++-
> + src/coordinator.c | 32 +++++++++++++++-----------------
> + 2 files changed, 20 insertions(+), 18 deletions(-)
> + mode change 100644 => 100755 src/coordinator.c
> +
> +diff --git a/lib/logging.c b/lib/logging.c
> +index 3ec30ee..f37531e 100644
> +--- a/lib/logging.c
> ++++ b/lib/logging.c
> +@@ -45,8 +45,12 @@ static void log_string(int level, char *s)
> + void init_log(char * name, int level)
> + {
> + #ifdef HAVE_SYSLOG_H
> ++ int option = LOG_PID|LOG_CONS|LOG_NOWAIT;
> ++
> + log_level = level;
> +- openlog(name, LOG_PID|LOG_CONS|LOG_NOWAIT, LOG_DAEMON);
> ++ if (log_level > 0)
> ++ option |= LOG_PERROR;
> ++ openlog(name, option, LOG_DAEMON);
> + #endif
> + }
> +
> +diff --git a/src/coordinator.c b/src/coordinator.c
> +old mode 100644
> +new mode 100755
> +index a09633a..3322e3e
> +--- a/src/coordinator.c
> ++++ b/src/coordinator.c
> +@@ -64,10 +64,10 @@ extern int yydebug;
> +
> + static void cleanup(int ret);
> +
> +-static void log_msg_nl_perror(char *s, int err)
> ++static void log_msg_nl_perror(const char *s, int res)
> + {
> +- if (err != NLE_SUCCESS) {
> +- log_msg(0, "%s: %s", s, nl_geterror(err));
> ++ if (res < 0) {
> ++ log_msg(0, "%s: %s", s, nl_geterror(-res));
> + cleanup(1);
> + }
> + }
> +@@ -93,8 +93,8 @@ static int mlme_start(uint16_t short_addr, uint16_t pan, uint8_t channel, uint8_
> + nla_put_u8(msg, IEEE802154_ATTR_BAT_EXT, 0);
> + nla_put_u8(msg, IEEE802154_ATTR_COORD_REALIGN, 0);
> + #endif
> +- int err = nl_send_auto_complete(nl, msg);
> +- log_msg_nl_perror("nl_send_auto_complete", err);
> ++ int res = nl_send_auto_complete(nl, msg);
> ++ log_msg_nl_perror("nl_send_auto_complete", res);
> + return 0;
> + }
> +
> +@@ -127,9 +127,9 @@ static int coordinator_associate(struct genlmsghdr *ghdr, struct nlattr **attrs)
> + nla_put_u64(msg, IEEE802154_ATTR_DEST_HW_ADDR, nla_get_u64(attrs[IEEE802154_ATTR_SRC_HW_ADDR]));
> + nla_put_u16(msg, IEEE802154_ATTR_DEST_SHORT_ADDR, shaddr);
> +
> +- int err = nl_send_auto_complete(nl, msg);
> ++ int res = nl_send_auto_complete(nl, msg);
> +
> +- log_msg_nl_perror("nl_send_auto_complete", err);
> ++ log_msg_nl_perror("nl_send_auto_complete", res);
> +
> + return 0;
> + }
> +@@ -308,7 +308,6 @@ int main(int argc, char **argv)
> + #else
> + opt = getopt(argc, argv, "l:f:d:m:n:i:s:p:c:hv");
> + #endif
> +- fprintf(stderr, "Opt: %c (%hhx)\n", opt, opt);
> + if (opt == -1)
> + break;
> +
> +@@ -364,7 +363,6 @@ int main(int argc, char **argv)
> + usage(pname);
> + return -1;
> + }
> +- lease_file[sizeof(lease_file)-1] = '\0';
> + if (debug > 1)
> + yydebug = 1; /* Parser debug */
> + else
> +@@ -396,19 +394,19 @@ int main(int argc, char **argv)
> + sa.sa_handler = SIG_IGN;
> + sigaction(SIGPIPE, &sa, NULL);
> +
> +- int err = NLE_SUCCESS;
> ++ int res = 0;
> + nl = nl_socket_alloc();
> +
> + if (!nl) {
> +- log_msg_nl_perror("nl_sock_alloc", NLE_NOMEM);
> ++ log_msg_nl_perror("nl_sock_alloc", -NLE_NOMEM);
> + return 1;
> + }
> +
> +- err = genl_connect(nl);
> +- log_msg_nl_perror("genl_connect", err);
> ++ res = genl_connect(nl);
> ++ log_msg_nl_perror("genl_connect", res);
> +
> + family = genl_ctrl_resolve(nl, IEEE802154_NL_NAME);
> +- log_msg_nl_perror("genl_ctrl_resolve", NLE_NOMEM);
> ++ log_msg_nl_perror("genl_ctrl_resolve", family);
> +
> + nl_socket_add_membership(nl, nl_get_multicast_id(nl, IEEE802154_NL_NAME, IEEE802154_MCAST_COORD_NAME));
> +
> +@@ -449,7 +447,7 @@ int main(int argc, char **argv)
> + return 2;
> + }
> + }
> +- pid_fd = open (PID_FILE, O_WRONLY | O_CREAT, 0640);
> ++ pid_fd = open (pid_file, O_WRONLY | O_TRUNC | O_CREAT, 0640);
> + if (pid_fd < 0) {
> + perror ("open");
> + return 1;
> +@@ -469,8 +467,8 @@ int main(int argc, char **argv)
> + mlme_start(short_addr, pan, channel, 1, iface);
> +
> + while (!die_flag) {
> +- err = nl_recvmsgs_default(nl);
> +- log_msg_nl_perror("nl_recvmsgs", err);
> ++ res = nl_recvmsgs_default(nl);
> ++ log_msg_nl_perror("nl_recvmsgs", res);
> + }
> + cleanup(0);
> +
> diff --git a/patches/lowpan-tools-0.3/series b/patches/lowpan-tools-0.3/series
> new file mode 100644
> index 0000000..7f7c24f
> --- /dev/null
> +++ b/patches/lowpan-tools-0.3/series
> @@ -0,0 +1 @@
> +0001-Avoid-crashing-in-izcoordinator.patch
> --
> 1.8.1.4
>
>
> --
> ptxdist mailing list
> ptxdist@pengutronix.de
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
--
ptxdist mailing list
ptxdist@pengutronix.de
prev parent reply other threads:[~2013-03-04 16:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-28 17:20 Alexander Aring
2013-03-04 16:40 ` Michael Olbrich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130304164040.GV5360@pengutronix.de \
--to=m.olbrich@pengutronix.de \
--cc=ptxdist@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox