Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 22 Jan 2019 13:11:15 +0000 (UTC)
From:      Stefan Esser <se@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343303 - head/usr.sbin/kbdmap
Message-ID:  <201901221311.x0MDBFic002121@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: se
Date: Tue Jan 22 13:11:15 2019
New Revision: 343303
URL: https://svnweb.freebsd.org/changeset/base/343303

Log:
  Silence a CI warning regarding the use of strcpy().
  
  While this is a false positive (a sufficiently large buffer has been
  allocated in the line above), the use of strdup() simplifies and clarifies
  the code.
  
  MFC after:	2 weeks

Modified:
  head/usr.sbin/kbdmap/kbdmap.c

Modified: head/usr.sbin/kbdmap/kbdmap.c
==============================================================================
--- head/usr.sbin/kbdmap/kbdmap.c	Tue Jan 22 12:56:49 2019	(r343302)
+++ head/usr.sbin/kbdmap/kbdmap.c	Tue Jan 22 13:11:15 2019	(r343303)
@@ -241,8 +241,7 @@ get_font(void)
 				if (strcmp(buf, "NO")) {
 					if (fnt)
 						free(fnt);
-					fnt = (char *) malloc(strlen(buf) + 1);
-					strcpy(fnt, buf);
+					fnt = strdup(buf);
 				}
 			}
 		}



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