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-XXXXXX", dir, pfx);

tools/initialconfig.c
465:  ret = asprintf(&archpath, "%s%c%s", dirpath, g_delim, entry->d_name);
469:              "ERROR: asprintf() failed to archpath\n");
473:  ret = asprintf(&testpath, "%s%cKconfig", archpath, g_delim);
477:              "ERROR: asprintf() failed to testpath\n");
485:      ret = asprintf(&testpath, "%s%cinclude", archpath, g_delim);
489:                  "ERROR: asprintf() failed to testpath/include\n");
497:          ret = asprintf(&testpath, "%s%csrc", archpath, g_delim);
501:                      "ERROR: asprintf() failed to testpath/src\n");
541:  ret = asprintf(&mcupath, "%s%c%s", dirpath, g_delim, entry->d_name);
545:              "ERROR: asprintf() failed to mcupath\n");
549:  ret = asprintf(&testpath, "%s%cKconfig", mcupath, g_delim);
553:              "ERROR: asprintf() failed to archpath/Kconfig\n");
560:      ret = asprintf(&testpath, "%s%cMake.defs", mcupath, g_delim);
564:                  "ERROR: asprintf() failed to testpath/Make.defs\n");
605:  ret = asprintf(&configpath, "%s%c%s%cdefconfig",
610:              "ERROR: asprintf() failed to configpath\n");
624:      ret = asprintf(&varvalue, "\"%s\"", g_selected_mcu);
628:                  "ERROR: asprintf() failed to varvalue\n");
696:  ret = asprintf(&boardpath, "%s%c%s", dirpath, g_delim, entry->d_name);
700:              "ERROR: asprintf() failed to boardpath\n");
704:  ret = asprintf(&testpath, "%s%cKconfig", boardpath, g_delim);
708:              "ERROR: asprintf() failed to testpath\n");
715:      ret = asprintf(&testpath, "%s%cinclude", boardpath, g_delim);
719:                  "ERROR: asprintf() failed to testpath\n");
726:          ret = asprintf(&testpath, "%s%csrc", boardpath, g_delim);
730:                      "ERROR: asprintf() failed to archpath\n");
913:  ret = asprintf(&archpath, "%s%c%s%csrc",
918:              "ERROR: asprintf() failed to archpath/src\n");

tools/incdir.c
211:static int my_asprintf(char **strp, const char *fmt, ...)
415:                  ret = my_asprintf(&segment, "%s'%s'", cmdarg,
incpath);
419:                  ret = my_asprintf(&segment, "%s'%s", cmdarg, incpath);
426:                  ret = my_asprintf(&segment, ";%s'", incpath);
430:                  ret = my_asprintf(&segment, ";%s", incpath);
444:              ret = my_asprintf(&segment, "%s \"%s\"", cmdarg, incpath);
448:              ret = my_asprintf(&segment, " %s \"%s\"", cmdarg,
incpath);

tools/kconfig2html.c
2295:                              asprintf(&dirpath, "%s/%s%s%s",
2300:                              asprintf(&dirpath, "%s/%s",
g_kconfigroot, subdir);
2435:  asprintf(&kconfigpath, "%s/%s", kconfigdir, kconfigname);

tools/gencromfs.c
1114:  ret = asprintf(&path, "%s/%s", dirpath, name);
1144:  ret = asprintf(&path, "%s/%s", dirpath, name);

arch/xtensa/src/esp32/esp32_wifi_adapter.c
3006:  ret = asprintf(&index_name, "%s", name);
3093:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);
3168:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);
3236:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);

arch/xtensa/src/esp32s3/esp32s3_wifi_adapter.c
2914:  ret = asprintf(&index_name, "%s", name);
3001:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);
3076:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);
3144:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);

arch/risc-v/src/esp32c3/esp32c3_wifi_adapter.c
3142:  ret = asprintf(&index_name, "%s", name);
3229:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);
3304:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);
3372:  ret = asprintf(&dir, NVS_DIR_BASE"%s.%s", index_name, key);

fs/unionfs/fs_unionfs.c
717:          ret = asprintf(&relpath, "%s%s", path, name);
721:          ret = asprintf(&relpath, "%s/%s", path, name);

fs/vfs/fs_dir.c
603:  asprintf(&dir->fd_path, "%s%s/", path_prefix, relpath);

fs/vfs/fs_rename.c
131:          asprintf(&subdir, "%s/%s", newpath, subdirname);
372:                  asprintf(&subdir, "%s/%s", newrelpath,

fs/inode/fs_inodesearch.c
356:                                  asprintf(&buffer,
484:      asprintf(&desc->buffer, "%s/%s", _inode_getcwd(), desc->path);

On Wed, Mar 29, 2023 at 12:02 PM Fotis Panagiotopoulos <f.j.pa...@gmail.com>
wrote:

> > 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 do that. Apart from asprintf() and vasprintf(), is anyone aware of
> any other similarly suspicious functions to check?
>
> > 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 pointer to NULL seems more safe, but also it is a change in
> functionality!
>
> Consider the following example:
>
> char * msg = "Error message";
> asprintf(&msg, "format string", args...);
>
> Based on the current functionality, I can directly use msg without any
> error checking, as it will always be valid.
> (Either due to its initialization, or due to a successful asprintf).
>
> Indeed, this seems like a not-so-great piece of code, but I don't know
> whether this approach is used anywhere in NuttX
> (or in user code).
>
>
>
> On Wed, Mar 29, 2023 at 3:28 AM Tomek CEDRO <to...@cedro.info> wrote:
>
>> 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 :-) :-)
>>
>> --
>> CeDeROM, SQ7MHZ, http://www.tomek.cedro.info
>>
>

Reply via email to