From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 92C92A046B for ; Mon, 22 Jul 2019 03:06:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1AAA837B4; Mon, 22 Jul 2019 03:06:51 +0200 (CEST) Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) by dpdk.org (Postfix) with ESMTP id 66D492BAC; Mon, 22 Jul 2019 03:06:49 +0200 (CEST) Received: by mail-ot1-f50.google.com with SMTP id n5so38506594otk.1; Sun, 21 Jul 2019 18:06:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iMuqUQhDGO+16Fd6Dz9kp1QKa7pcMT6dKonZY/kBlxc=; b=E7o72sdxNLNM2wQ/a6NxiQG+39jEDf51JGGR3zCmWAvluSS9utqSGfGmpxi5G54/Me WlU9685E+IpqAz07MWdPSR3ktlbLzDS2OkVR/gVMi+mPiM31IHE61EAAtCBNsk3a7aGw KGPIkUC3Q3OPFFirlqtcVnNaHyyofQ2cqGb29KN7BRvJO4ExDwSC7QOetP773X3jxucB t/XDv11xYniiLmv0NoVrUZXbWXpdW3n2toG42SfZXR9x0j76qu9ahJuozg2nJdlIHN6i vu9rq2CUOJvJgC/dQfs3c3245Yq7U0SBg52BDMPYN46w2UzjQ1721tCix5suw6uFqJzy V9ig== 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=iMuqUQhDGO+16Fd6Dz9kp1QKa7pcMT6dKonZY/kBlxc=; b=qiSsQ0jXBpL9/C13Lteezg6dgMcflEMh2Tv22SC16FQs7ssGaJdzzwTvVMkTBtd0et gqhqy0/RQ9W/WVibZ5MlGjnx8+PjL87ZCT5F6CDZ2vPzKxRrmDZPG6BLtzqI1/JR9C/0 LldM4u6AZIa5+ba5tRsT5lh5IPjf5nbGTqrDfP49JVhRdVyMcIRoVR7yEqKrx02CUu/m BBRoxjpX6o1/S7MPPar0GxiRM0N9bDTMy0wmFijYHKm6B1qxynPHwTY+Qj8H7RPAACre +boD2wGiQA38LLc+F7Nt8aDYQ8J7Pp0bCUm8lDBlkOwpcbFGMxxjK+dtTkRVnCdxTPCl QVuQ== X-Gm-Message-State: APjAAAU3ynOMuefAk3GhJIQGqNsWpuRI652oRv39axQQNjTkY2aUJ6kU oIuPgAauHmrdBHmQcKtevS/kVtx3PJQTdUdd3NI= X-Google-Smtp-Source: APXvYqxAxlBmihU1To0vC5nNVwI89U01MBn6wBYXC1/XkWRCbHdh49pXgE/xTHa1T0LeIAaFmIJODcaK0NC3HHrGMCw= X-Received: by 2002:a9d:4b02:: with SMTP id q2mr13218635otf.312.1563757608735; Sun, 21 Jul 2019 18:06:48 -0700 (PDT) MIME-Version: 1.0 References: <1555379952-23517-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> <20190711103148.9187-1-yasufum.o@gmail.com> <20190711103148.9187-2-yasufum.o@gmail.com> <99d2853d-f6f9-59f2-f853-0f9222e8cb5d@gmail.com> In-Reply-To: <99d2853d-f6f9-59f2-f853-0f9222e8cb5d@gmail.com> From: Ogawa Yasufumi Date: Mon, 22 Jul 2019 10:06:37 +0900 Message-ID: To: "Burakov, Anatoly" , david.marchand@redhat.com Cc: dev@dpdk.org, stable@dpdk.org, Yasufumi Ogawa Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: Re: [dpdk-dev] [PATCH v3 1/1] fbarray: get fbarrays from containerized secondary X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 2019=E5=B9=B47=E6=9C=8812=E6=97=A5(=E9=87=91) 11:22 Yasufumi Ogawa : > On 2019/07/11 22:14, Burakov, Anatoly wrote: > > On 11-Jul-19 12:57 PM, Yasufumi Ogawa wrote: > >> On 2019/07/11 19:53, Burakov, Anatoly wrote: > >>> On 11-Jul-19 11:31 AM, yasufum.o@gmail.com wrote: > >>>> From: Yasufumi Ogawa > >>>> > >>> <...> > >>> > >>>> + if (getpid() =3D=3D 1) { > >>>> + FILE *hn_fp; > >>>> + hn_fp =3D fopen("/etc/hostname", "r"); > >>>> + if (hn_fp =3D=3D NULL) { > >>>> + RTE_LOG(ERR, EAL, > >>>> + "Cannot open '/etc/hostname' for secondary\n"); > >>>> + return -1; > >>>> + } > >>>> + > >>>> + /* with docker, /etc/hostname just has one entry of > >>>> hostname */ > >>>> + if (fscanf(hn_fp, "%s", proc_id) =3D=3D EOF) { > >>> > >>> Apologies for not pointing this out earlier, but do i understand > >>> correctly that there's no bounds checking here, and fscanf() will > >>> write however many bytes it wants? > >> I understand "%s" is not appropriate. hostname is 12 bytes char and I > >> thought proc_id[16] is enough, but it is unsafe. In addition, hostname > >> can be defined by user with docker's option, so it should be enough > >> for user defined name. > >> > >> How do you think expecting max 32 chars of hostname and set boundary > >> "%32s" as following? > >> > >> proc_id[33]; /* define proc id from hostname less than 33 bytes. > */ > >> ... > >> if (fscanf(hn_fp, "%32s", proc_id) =3D=3D EOF) { > >> > > > > As long as it takes NULL-termination into account as well, it should be > > OK. I can't recall off the top of my head if %32s includes NULL > > terminator (probably not?). > Do you agree if initialize with NULL chars to ensure proc_id is > NULL-terminated? As tested on my environment, "%Ns" sets next of Nth > char as NULL, but it seems more reliable. > proc_id[33] =3D { 0 }; > Hi Anatoly, I would like to send v4 patch if it is agreeable. > > Yasufumi >