Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Oct 2011 22:16:25 GMT
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 199874 for review
Message-ID:  <201110072216.p97MGPN6000115@skunkworks.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@199874?ac=10

Change 199874 by pjd@pjd_anger on 2011/10/07 22:15:34

	Simplify code by using strdup().

Affected files ...

.. //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#48 edit

Differences ...

==== //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#48 (text+ko) ====

@@ -26,7 +26,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#47 $
+ * $P4: //depot/projects/trustedbsd/openbsm/bin/auditd/auditd.c#48 $
  */
 
 #include <sys/types.h>
@@ -155,18 +155,15 @@
 {
 	char *ptr;
 	char *oldname;
-	size_t len;
 
 	/* If lastfile is NULL try to get it from the 'current' link.  */
 	if (lastfile == NULL)
 		lastfile = get_curfile();
 
 	if (lastfile != NULL) {
-		len = strlen(lastfile) + 1;
-		oldname = (char *)malloc(len);
+		oldname = strdup(lastfile);
 		if (oldname == NULL)
 			return (-1);
-		strlcpy(oldname, lastfile, len);
 
 		/* Rename the last file -- append timestamp. */
 		if ((ptr = strstr(lastfile, NOT_TERMINATED)) != NULL) {



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