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=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28790 invoked from network); 12 May 2022 20:58:51 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 12 May 2022 20:58:51 -0000 Received: (qmail 12076 invoked by uid 550); 12 May 2022 20:58:48 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 12041 invoked from network); 12 May 2022 20:58:47 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=tgmFxg2F1VD/MdSH/W7f4SDWtKgsq+8m7nDNZNaQpLA=; b=UgzlxBMHMdTgAKcyeMjLryoMJKopkdx9cfWfV1XLsW5H8+pIbzyc0cr+4TyC59g81V ZzrpA1I6FTUbkpxPDF+bcAgJhN5mUDeZbDc8OmOrZouRR6NIPgNNq50GVhi5T/svJ0/A gHDkHRmTj5GxpEtHqKAiitJQy3DalIYfGiJoM76vd182NIPWCWCaS1UFsvoaG8d0PLOq 03NyO4m8WqENuSpEB/9wBSG0Eb/hK4uYGz/YqQkS+7N57limyle91WQq9Np6JQuNmDBf G12cA62gn0zS8Q22vyWWfbSm0Oc5/wbhYY2oGa5IgV/4SgHVa0niizc8PDbIfuI/x42h rwaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=tgmFxg2F1VD/MdSH/W7f4SDWtKgsq+8m7nDNZNaQpLA=; b=cWaeCRuvzXwQd9dSdASC1sEpPalpnPLVK3w7CzsncHqBnxrWguknPLTEd1PH1gQTmO 9xjnG2vcDs3Z7FUr9fBkQu1lj0LOKgIejLvVpJbzZVi4Ty0s40hZX1ynISCPYMZl5e+K AP2TNvlff7gV74O80ZJZFKveLffe54MNy65AwPycsswAAu8pWzNMWlthDgvLyHlv+t6D KhztKquie5LIVZmtrl4cSS1FB/nJoo5PHi/nRXVu4IlToEflV6V5aWpeFWmexV0Lwl6x IzAJvozBKAXVodAzZCtDcjz1mKp2zktPBYt+CZhw02riegFFW5wfY1WpUSWyUeP51r8Y CZrQ== X-Gm-Message-State: AOAM530f1jvg5a2+tNM3T6/XmnW2F14DS4rs4hbO4KhDyp8SjiaPPmSi TMefXMGEjridSoNAd03KGnKTZILwlYvzlvwvCxVW0T/8d0o= X-Google-Smtp-Source: ABdhPJy54qXMzqrM3v3QaFKSepT643Q3H3pZKPB9uMlkGStKc8AWKtp2yh1O1qZZ1dp+ERgo/KDPTAjVckRylmZZ+es= X-Received: by 2002:a05:6808:1825:b0:326:3e14:f156 with SMTP id bh37-20020a056808182500b003263e14f156mr909492oib.144.1652389115309; Thu, 12 May 2022 13:58:35 -0700 (PDT) MIME-Version: 1.0 References: <20210915221155.3977763-1-hi@alyssa.is> <20210915221155.3977763-4-hi@alyssa.is> <20210920042140.GT13220@brightrain.aerifal.cx> <20220109031819.GO7074@brightrain.aerifal.cx> <878rvj1tut.fsf@alyssa.is> <20220113174037.GA7074@brightrain.aerifal.cx> <875yqn1n8g.fsf@alyssa.is> <20220512140835.GJ7074@brightrain.aerifal.cx> In-Reply-To: <20220512140835.GJ7074@brightrain.aerifal.cx> From: Oliver Ford Date: Thu, 12 May 2022 21:58:30 +0100 Message-ID: To: musl@lists.openwall.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [musl] [PATCH musl v2 3/3] mntent: fix parsing lines with optional fields On Thu, May 12, 2022 at 3:08 PM Rich Felker wrote: > > - There's also an independent bug in hasmntent that was reported a > long time ago then lost: it will return false positives when one > mntopt name is a substring of another. strstr is just not the right > operation here, at least not without added logic to ensure matching > on a whole option boundary. This is a separate issue that calls for > a separate patch though, not a blocker on the patch under discussion > here. > Looking at this, the "hasmntopt" function does match options where the string is part of the option but not the whole option. So the opt "ro" will correctly match the "ro" (for read-only) option, but also match an option that contains "symlinkroot". The following version of the function keeps the initial strstr, but adds an extra check so that it doesn't match unless the next character is either a comma or nul. If there's no other special cases we need to handle, I'll submit as a patch? char *hasmntopt(const struct mntent *mnt, const char *opt) { char *op = strstr(mnt->mnt_opts, opt); if (op == NULL) return NULL; size_t len = strlen(opt); char *end = op + len; if (*end == '\0' || *end == ',') return op; return NULL; }