On Sat, Jan 15, 2022 at 01:50:19PM -0700, Martin Sebor wrote:
> Having said that, checking and handling possible truncation before
> calling snprintf() is doing double the work. I would suggest to get
> rid of the check and instead handle the truncation after it happens.
> This is both simpler and faster, and avoids the warning:
>
> if (snprintf (*sockpath, UNIX_PATH_MAX,
> "%s/%s", g->sockdir, filename) < UNIX_PATH_MAX)
> return 0;
>
> error (g, _("socket path too long: %s/%s"), g->sockdir, filename);
> return -1;
> }
Oh that's a good idea, thanks!
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
_______________________________________________
devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedoraproject.org/archives/list/[email protected]
Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure