From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 27963 invoked from network); 18 Dec 2020 11:19:45 -0000 Received: from ewsd.inri.net (107.191.116.128) by inbox.vuxu.org with ESMTPUTF8; 18 Dec 2020 11:19:45 -0000 Received: from mail-qk1-f174.google.com ([209.85.222.174]) by ewsd; Fri Dec 18 06:13:27 -0500 2020 Received: by mail-qk1-f174.google.com with SMTP id p14so1596275qke.6 for <9front@9front.org>; Fri, 18 Dec 2020 03:13:18 -0800 (PST) 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 :content-transfer-encoding; bh=VthGf9YEixbQ8CsPy45e04PwO3OololzsPik2/0iwNI=; b=uIO4F08mj1/ZG6BNE4SB9wTouijJSdPS8dSJSQsY5orQ68+yejWlGVeGD276J0TuzP BSWrera2fejMVXkZygqEoGUNa8EzT9Xlv4QseunQiUZkcQCQZFh9twXiFJ3yTHKfajdo woK7JSUJ783F9jSvCEf08y3MIHGYlofkNFmBbr5MS36mj2uyn6Y5Z3aEWSqQ10MB1/oN Om5Ks6QE/fKvml5QYqYtmyZblcpXc1rhkd8DLQd7XMnn329RP+H4TzeO1k8seD+7AcpX rdGFsfyAjoP1H9RGBB/cdSw4l5yoG+72M4a6asAY1ofHUhphCSnnpCVCswAzbSzrai5J 709Q== 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:content-transfer-encoding; bh=VthGf9YEixbQ8CsPy45e04PwO3OololzsPik2/0iwNI=; b=s/7Y/06r97u77CpjEJBDRNO8S2kbeQgH1C55XxgTy32juZ0MiZTx8/oDz2sXkJ9dxU PIoTu5YWu8/fXeSIr6o/rf9us2DqZHBOvqA9zy8Ikxv50HYri53VAPSrJWFbntL83JQq nn5dzVBuM+p5rFZkrBVxnxtV13QV4orvy/mExlmxTFOk6h6aV2Iqs0yMdqLAC3Jvwqvg nZuMkLqICc6YRpwI/arllnylosqqDAnhPDc4WbDpu5ABgYvYuMMvi+7mlN6VTfGnGWus IB1AiA50XtnSTIPR46i4DtY3kmyoP/hDIWkgLp5qR646I/aCcV+8zBZIqxf/k7RxhyMy 1rQA== X-Gm-Message-State: AOAM5301Zi48sKDLrsx+HT4aSJSVh28XdSLZbUVdwC5g0POz/HjAgFfu 6k6+6OKEl76n0ffBiCwe5VeP2c37ghb/QL8ax7/VAQaOA6A= X-Google-Smtp-Source: ABdhPJzhZcoLLds73Yyk152xbNqnf2/sF/rArTdr9bC82kQTadlscoETMpqlWpI9WrHtESu6SqQ07GCriVBTcA6DhKM= X-Received: by 2002:a37:64a:: with SMTP id 71mr4058896qkg.170.1608289521460; Fri, 18 Dec 2020 03:05:21 -0800 (PST) MIME-Version: 1.0 References: <54874114B98195307A5780FB707F9115@gmail.com> In-Reply-To: From: Eli Cohen Date: Fri, 18 Dec 2020 03:05:10 -0800 Message-ID: To: 9front@9front.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: property-oriented wrapper Subject: Re: [9front] strndup should use strnlen and memcpy Reply-To: 9front@9front.org Precedence: bulk it's kind of surprising to me, I wasn't able to find much more on google about it than this https://cseweb.ucsd.edu/classes/fa18/cse127-a/CSE127fa18.3-Savage.pdf On Fri, Dec 18, 2020 at 3:02 AM Eli Cohen wrote: > > I am very surprised either way :o > > it should definitely be strnlen... strn* are specifically for cases > where you want to specify a length, specifically where the strings are > not necessarily null-terminated > > this is probably all my fault, I apologize for horsing around. it does > seem like I saw the cover of a DVD of that movie wargames once but I'm > sure there's more to it...? > > On Fri, Dec 18, 2020 at 2:50 AM Kemal wrote: > > > > 2020-12-18 13:31 GMT+03:00, Sigrid Solveig Hafl=C3=ADnud=C3=B3ttir : > > >> Open Group does not specify if arg1 should be null terminated or not= . > > >> https://pubs.opengroup.org/onlinepubs/9699919799/functions/strdup.ht= ml > > > > > > "Applications should not assume that strndup() will allocate ( size += 1) > > > bytes when strlen(s) is smaller than size." > > > > > > Pretty sure this means it's supposed to be null-terminated, or > > > otherwise it wouldn't mention the "dangerous" strlen right there. > > > > > > > > I don't know, I also think that str is \0 terminated but that seems a > > bit unclear.