From owner-freebsd-hackers@freebsd.org Wed Sep 11 13:30:25 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id AFB07D4146 for ; Wed, 11 Sep 2019 13:30:25 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46T2p85Qnkz3xCY for ; Wed, 11 Sep 2019 13:30:24 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x82f.google.com with SMTP id g13so24810139qtj.4 for ; Wed, 11 Sep 2019 06:30:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=o81AbNy5QkwIcb591v6oYyuRy+dtGV0Dp5xjOHbf1KM=; b=drdjYXWIFAq19rKzw0LSOD/MRa65+ek8MMXnjSh/Zg4HZzaZgQ/BmvmUpBiIAio/aj 24PpRVPWac7tTuVbphkFFhYmn4HtNjtv7yDNb7narZKnckaBGvs7Hw2xf0nDpoQDC+2Q 9FbUTU262O1wSP2ZAqIU2tFEA9Bh5xiuVwlOTgJfQj+k6KL7YDwq/gHsnH4MBWx8w/Ka tX+blSi9D+DduPz93cfCuRNiwVR6qwViRnOAWdLv5BvOeEUlQ54k6JIUs8OH/sNP3sQ5 NMJZ1tHM4U30MD81vPHG3ehYIAM5wXukFqLTdar7h4KPzbGIFd3aq0NIjeq52r3DN4cP S2Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=o81AbNy5QkwIcb591v6oYyuRy+dtGV0Dp5xjOHbf1KM=; b=gxD88NDhrXGRyzd9xgI5pDLxWdL7aL8FJE8+e9EdcMXc5u4UmeqrBp562j6BU6lR61 J9S14NiDnBIg8c1baAZO6ORWgl4Rh1+39lPTcEZOGfcDJ7+CCvv8tTl872WP8z0gm7qI go1yCTkEDzyUso2S4w8QbmsaxXYhuOOZJwu2O6pD9J7zKUloNZRynJyAtVNmld/w7WPT OznR4dKobGS8eoj8YDCjVTxAcchtPAu01qnUq1rDK71rQta/KYiBrWf9VCun7GlUrbH6 2nKUjbixLpiPsSibh9iQQrBxMrGrse+J9k5/bEMGsE5R8EizftGKYWOUDpcChh2QTJuW tcqQ== X-Gm-Message-State: APjAAAWHZtP2CEzsiHDE5VHqcjha0x1TGQrUASkba//HEyzrVmO5diQS KZakQBaXbSqqnf5XtVo0rTTbKSmoWVFT8qUmydP76w== X-Google-Smtp-Source: APXvYqy58qsu0hxtXVt6D/qaqy+bY4TuQKKVU/BQ2vyzeCVjKUdOuAp0FAe6JZZcyXm9K/Kgibkw/6MO+mxMFG5Aupk= X-Received: by 2002:ac8:3364:: with SMTP id u33mr35329653qta.187.1568208623348; Wed, 11 Sep 2019 06:30:23 -0700 (PDT) MIME-Version: 1.0 References: <20190911082833.32388-1-sebastian.huber@embedded-brains.de> In-Reply-To: <20190911082833.32388-1-sebastian.huber@embedded-brains.de> From: Warner Losh Date: Wed, 11 Sep 2019 07:30:11 -0600 Message-ID: Subject: Re: [PATCH] nvmecontrol: Fix shortopts allocation To: Sebastian Huber Cc: "freebsd-hackers@freebsd.org" X-Rspamd-Queue-Id: 46T2p85Qnkz3xCY X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=drdjYXWI; dmarc=none; spf=none (mx1.freebsd.org: domain of wlosh@bsdimp.com has no SPF policy when checking 2607:f8b0:4864:20::82f) smtp.mailfrom=wlosh@bsdimp.com X-Spamd-Result: default: False [-3.88 / 15.00]; ARC_NA(0.00)[]; TO_DN_EQ_ADDR_SOME(0.00)[]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; URI_COUNT_ODD(1.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; RCPT_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[f.2.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; MIME_TRACE(0.00)[0:+,1:+,2:~]; IP_SCORE(-2.88)[ip: (-9.36), ipnet: 2607:f8b0::/32(-2.72), asn: 15169(-2.25), country: US(-0.05)]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Sep 2019 13:30:25 -0000 On Wed, Sep 11, 2019 at 2:28 AM Sebastian Huber < sebastian.huber@embedded-brains.de> wrote: > Account for potential ':' in the short options string. > --- > sbin/nvmecontrol/comnd.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sbin/nvmecontrol/comnd.c b/sbin/nvmecontrol/comnd.c > index d8d97ad11b5..a91969ff766 100644 > --- a/sbin/nvmecontrol/comnd.c > +++ b/sbin/nvmecontrol/comnd.c > @@ -189,7 +189,7 @@ arg_parse(int argc, char * const * argv, const struct > cmd *f) > lopts = malloc((n + 2) * sizeof(struct option)); > if (lopts == NULL) > err(1, "option memory"); > - p = shortopts = malloc((n + 3) * sizeof(char)); > + p = shortopts = malloc((2 * n + 2) * sizeof(char)); > I'll apply, but I still think this needs to be + 3 to account for the NUL at the end (even though we kinda know that the 2 options we're adding don't have :. > if (shortopts == NULL) > err(1, "shortopts memory"); > idx = 0; > -- > 2.16.4 > > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >