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 26687 invoked from network); 18 Dec 2020 11:07:27 -0000 Received: from ewsd.inri.net (107.191.116.128) by inbox.vuxu.org with ESMTPUTF8; 18 Dec 2020 11:07:27 -0000 Received: from mail-qv1-f53.google.com ([209.85.219.53]) by ewsd; Fri Dec 18 06:02:33 -0500 2020 Received: by mail-qv1-f53.google.com with SMTP id et9so656049qvb.10 for <9front@9front.org>; Fri, 18 Dec 2020 03:02:24 -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=e7Q6bYy/UvcwXZdQeODxzA3zqCmd64kCiq3Qxi7faVM=; b=JdRrUCu61jzKQrziKs86Jg+VyYTZM9L0T2zUaE2RwhXo/50iigwEWP6trrXVnIX+qm MkzSyKZqY4ZIJG8ntvqng69/z+BAEpGBH3CDMD5VWj2vLFGEdeA9EfNy7wfW4mkHwCtY MRKxQUN9EFk+VNIGvFyEs2cf3LfUWP0Bw83HVEvlTBesPuyQjOarvh2SDxh65yRhfEg/ gyd/JsIGW9VtJwOvLXxa90OeYesS59FSB35pi66lY6Ew4/1XmDeFUn3VN2bGQIzJglkt UWDV8/qUFwFFTqqh7TMukaPRZIdKEnU6R8ziSyAvOpvADx1NuR889XKrviqruobJwPVf gTrw== 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=e7Q6bYy/UvcwXZdQeODxzA3zqCmd64kCiq3Qxi7faVM=; b=KRH3nmTwOt5sKWMGZ+QrZTMUwqWjzBJ5yZrC/h0roYZoY0Tg7jsxUXqmlFqxMn9x17 AC9TlWGER8xOoNjg7X7JcKp2W4jyvzH6XyLT8VyTLcZbm0U54PJH6RIbnB7JVx2jBgBN vzu7w4/Io/L3DrQ/DbXrIC0d/VGGYVRvHpZZedmKSBCoKvol+zEggoax7RPbjFO/4FEw FNwYAnfmztME+4ENB4LFEoeN92K2X9Lc3zMJS1BVgiJ0iIAMDAZPKhzRlxUMtkYNvb6Q LybxkFc9Hyfe/2rtDnb6KEC6rkAH3Dr0pdWlHlcch4je1aUioqhEfMTvg6LgXzMPeKzn 5PMw== X-Gm-Message-State: AOAM530fuMM8vsqgxdnUi/3sACuxtv2VOfW+bSX/oxHvj5iWKOaV+BRk tflMWka98C3FNf+FIz5+ksBp9Dt1BxFA/hWzw7M9c+Tm X-Google-Smtp-Source: ABdhPJwz5iAKHU5L7MOb6L75TFxdWHQKDtiZJGwZn+VvW4rCXSPZz9jEcBVGXEqiyYZrf+7piXKIqgbXLtia9SqDQUo= X-Received: by 2002:a0c:916d:: with SMTP id q100mr3829542qvq.29.1608289343714; Fri, 18 Dec 2020 03:02:23 -0800 (PST) MIME-Version: 1.0 References: <54874114B98195307A5780FB707F9115@gmail.com> In-Reply-To: From: Eli Cohen Date: Fri, 18 Dec 2020 03:02:12 -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: package self-signing cloud pipelining locator Subject: Re: [9front] strndup should use strnlen and memcpy Reply-To: 9front@9front.org Precedence: bulk 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.html > > > > "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.