[Git][NTPsec/ntpsec][master] ntpd: simplify -u handling, fix 2 coverity warnings.

Gary E. Miller gitlab at mg.gitlab.com
Thu May 25 20:26:05 UTC 2017


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
ff1d94c0 by Gary E. Miller at 2017-05-25T13:25:05-07:00
ntpd: simplify -u handling, fix 2 coverity warnings.

Also remove unneeded malloc()s.

- - - - -


1 changed file:

- ntpd/ntpd.c


Changes:

=====================================
ntpd/ntpd.c
=====================================
--- a/ntpd/ntpd.c
+++ b/ntpd/ntpd.c
@@ -352,19 +352,18 @@ parse_cmdline_opts(
 	    case 'u':
 #ifdef ENABLE_DROPROOT
 		if (ntp_optarg != NULL) {
+                        char *gp;
+
 			droproot = true;
-			/* coverity[overwrite_var] Leak is real but harmless */
-			user = estrdup(ntp_optarg);
-			/* coverity[overwrite_var] Leak is real but harmless */
-			group = strrchr(user, ':');
-			if (group != NULL) {
-				size_t	len;
-
-				*group++ = '\0'; /* get rid of the ':' */
-				len = (size_t)(group - user);
-				group = estrdup(group);
-				user = erealloc(user, len);
-			}
+			user = ntp_optarg;
+
+			gp = strrchr(user, ':');
+			if (gp) {
+				*gp++ = '\0'; /* get rid of the ':' */
+				group = gp;
+			} else {
+                                group  = NULL;
+                        }
 		}
 #endif
 		break;



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/ff1d94c030898378b82e1fec7c119259e9b1e765

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/ff1d94c030898378b82e1fec7c119259e9b1e765
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170525/081a6bdf/attachment.html>


More information about the vc mailing list