-/* $OpenBSD: parse.y,v 1.29 2018/08/03 17:57:21 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.30 2018/09/07 07:35:30 miko Exp $ */
/*
* Copyright (c) 2016 Kristaps Dzonsons <kristaps@bsd.lv>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return -1;
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(EXIT_FAILURE, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(EXIT_FAILURE, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.334 2018/09/07 05:43:33 claudio Exp $ */
+/* $OpenBSD: parse.y,v 1.335 2018/09/07 07:35:30 miko Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- fatal("cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ fatal("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.36 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.37 2018/09/07 07:35:30 miko Exp $ */
/*
* Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.27 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.28 2018/09/07 07:35:30 miko Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.105 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.106 2018/09/07 07:35:30 miko Exp $ */
/*
* Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.52 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.53 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
+ sym = strndup(s, val - s);
+ if (sym == NULL)
err(1, "%s", __func__);
-
- strlcpy(sym, s, len);
-
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.15 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.16 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2010 David Gwynne <dlg@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.32 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.33 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2009, 2010 Martin Hedenfalk <martinh@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- fatal("cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ fatal("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.65 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.66 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.3 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.4 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "%s", __func__);
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.38 2018/07/12 13:45:03 remi Exp $ */
+/* $OpenBSD: parse.y,v 1.39 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.91 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.92 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.8 2018/08/03 13:14:46 florian Exp $ */
+/* $OpenBSD: parse.y,v 1.9 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.227 2018/08/06 17:31:31 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.228 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.41 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.42 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.220 2018/09/05 08:47:34 gilles Exp $ */
+/* $OpenBSD: parse.y,v 1.221 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2008 Gilles Chehade <gilles@poolp.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.51 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.52 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.10 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.11 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = (val - s) + 1;
- if ((sym = malloc(len)) == NULL)
- fatal("cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ fatal("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.42 2018/07/13 08:42:49 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.43 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = (val - s) + 1;
- if ((sym = malloc(len)) == NULL)
- fatal("cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ fatal("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);
-/* $OpenBSD: parse.y,v 1.28 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.29 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "%s", __func__);
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);