Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Jul 2001 19:01:27 -0400 (EDT)
From:      Mike Heffner <mheffner@novacoxmail.com>
To:        Mike Barcroft <mike@q9media.com>
Cc:        audit@FreeBSD.org
Subject:   Re: Teach tmpfile(3) about TMPDIR
Message-ID:  <XFMail.20010706190127.mheffner@novacoxmail.com>
In-Reply-To: <200107060405.f66451H10795@coffee.q9media.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This message is in MIME format
--_=XFMail.1.5.0.FreeBSD:20010706190127:70043=_
Content-Type: text/plain; charset=us-ascii


On 06-Jul-2001 Mike Barcroft wrote:
| Mike Heffner <mheffner@novacoxmail.com> writes:
| [...]
| +       buf = malloc(tmpdirlen + (tmpdir[tmpdirlen - 1] == '/') ? 0 : 1 +
| +           sizeof(TRAILER));
| +       if (buf == NULL)
| +               return NULL;
| +       (void)sprintf(buf, "%s%s%s", tmpdir,
| +           (tmpdir[tmpdirlen - 1] == '/') ? "" : "/", TRAILER);
| [...]
| 
| Why not use asprintf(3) instead?  Like:
| (void)asprintf(&buf, "%s%s%s", tmpdir,
|     (tmpdir[strlen(tmpdir) - 1] == '/') ? "" : "/", TRAILER);
| if (buf == NULL)
|       return NULL;

No real reason. I was a little unsure on what errno was set to, if at all, on
failure (printf(3) doesn't really state anything), but looking at the code it
looks like it'll only return ENOMEM, so it's probably safe to use.

Mike

-- 
  Mike Heffner         <mheffner@[acm.]vt.edu>
  Fredericksburg, VA       <mikeh@FreeBSD.org>


--_=XFMail.1.5.0.FreeBSD:20010706190127:70043=_
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7RkNGFokZQs3sv5kRAiZKAJ9d7aKouME/+wONsySxUt4m4A37LgCePhCg
jYm8OJS7Na5K2JtOnP4y3mw=
=a4WU
-----END PGP SIGNATURE-----

--_=XFMail.1.5.0.FreeBSD:20010706190127:70043=_--
End of MIME message

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-audit" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.20010706190127.mheffner>