Re: asprintf failure

2023-04-27 Thread Fotis Panagiotopoulos
Indeed your suggestion is valid. I created the following issues: https://github.com/apache/nuttx/issues/9126 https://github.com/apache/nuttx-apps/issues/1727 On Thu, Apr 27, 2023 at 5:06 AM Nathan Hartman wrote: > On Wed, Apr 26, 2023 at 9:32 AM Fotis Panagiotopoulos > wrote: > > > > Hello, >

Re: asprintf failure

2023-04-26 Thread Nathan Hartman
On Wed, Apr 26, 2023 at 9:32 AM Fotis Panagiotopoulos wrote: > > Hello, > > I fixed all critical usages of asprintf and strdup. > > These fixes are in the following PRs: > https://github.com/apache/nuttx/pull/9009 > https://github.com/apache/nuttx/pull/9010 > https://github.com/apache/nuttx-apps/p

Re: asprintf failure

2023-04-26 Thread Fotis Panagiotopoulos
Hello, I fixed all critical usages of asprintf and strdup. These fixes are in the following PRs: https://github.com/apache/nuttx/pull/9009 https://github.com/apache/nuttx/pull/9010 https://github.com/apache/nuttx-apps/pull/1713 The OS itself is now fixed, there should be no other issues pending

Re: asprintf failure

2023-03-29 Thread Nathan Hartman
On Wed, Mar 29, 2023 at 5:02 AM Fotis Panagiotopoulos wrote: > > In my opinion asprintf should set the pointer to NULL, to be safe. > > But the calling code should probably be changed as well, because it is > > not a good coding example for portability. > > I'm sceptical about this. > Setting the

Re: asprintf failure

2023-03-29 Thread Fotis Panagiotopoulos
strdup() is much better used. Its functionality is simpler, and its behavior much better understood by most people. There are only two places with a strdup without checking the result: gs2200m.c, line 3503 nxffs_pack.c, line 1092 Either the original author forgot it, or it doesn't matter? There

Re: asprintf failure

2023-03-29 Thread Fotis Panagiotopoulos
> strdup? Thanks, I will check this too. I went through all the asprintf calls in the list. These are the ones that actually need to be fixed. Everything else is properly checked. drivers/net/telnet.c 698: ret = asprintf(&devpath, TELNET_DEVFMT, priv->td_minor); libs/libc/uuid/lib_uuid_to_

Re: asprintf failure

2023-03-29 Thread Gregory Nutt
I can do that. Apart from asprintf() and vasprintf(), is anyone aware of any other similarly suspicious functions to check? strdup?

Re: asprintf failure

2023-03-29 Thread Fotis Panagiotopoulos
Using ack, these are all uses of asprintf(): drivers/net/telnet.c 698: ret = asprintf(&devpath, TELNET_DEVFMT, priv->td_minor); libs/libc/uuid/lib_uuid_to_string.c 66: c = asprintf(s, libs/libc/stdio/lib_tempnam.c 78: asprintf(&template, "%s/%s-XX", dir, pfx); tools/initialconfig.c 4

Re: asprintf failure

2023-03-29 Thread Fotis Panagiotopoulos
> Since, as you point out, this may be a lot of work, I think we should > try to split the work across several devs... Yes please, I am beyond burn-out lately... > To do that, we'd grep for all uses of asprintf() to find out which > files use it and post that list in reply to this email. I can d

Re: asprintf failure

2023-03-28 Thread Tomek CEDRO
On Wed, Mar 29, 2023 at 2:14 AM Bernd Walter wrote: > I think I should open up a ticket for FreeBSD to extend this part in the > manpage. > Sounds like a trap - I often just look into the FreeBSD manpages, since this > is what my desktop runs. greetings from a FBSD station to a fellow daemon :-)

Re: asprintf failure

2023-03-28 Thread Bernd Walter
On Tue, Mar 28, 2023 at 04:28:58PM -0400, Nathan Hartman wrote: > On Tue, Mar 28, 2023 at 3:43 PM Fotis Panagiotopoulos > wrote: > > > > Hello, > > Replying inline below... > > > I just noticed that there are some problems with the usage of asprintf() > > throughout the code base. > > This funct

Re: asprintf failure

2023-03-28 Thread Nathan Hartman
On Tue, Mar 28, 2023 at 3:43 PM Fotis Panagiotopoulos wrote: > > Hello, Replying inline below... > I just noticed that there are some problems with the usage of asprintf() > throughout the code base. > This function is not properly checked for failure, which can lead to nasty > crashes. > > I am