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,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 16051 invoked from network); 14 May 2022 04:08:57 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 14 May 2022 04:08:57 -0000 Received: (qmail 31959 invoked by uid 550); 14 May 2022 04:08:54 -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 31927 invoked from network); 14 May 2022 04:08:53 -0000 Resent-From: Rich Felker Resent-Date: Sat, 14 May 2022 00:08:40 -0400 Resent-Message-ID: <20220514040840.GN7074@brightrain.aerifal.cx> Resent-To: musl@lists.openwall.com 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=EEMo9zIgXBYZX6w+vj40KEeWDGQ0HKmPSuSiDY8tumk=; b=T5Bbfy2Zi78JevKBYyIASRPPfjyj7XchvDfIyIszjpi0FIbrkiwFM6RDSq5kViIFaU Kpk6EAHlGHNGSarX62ZsTlWxISgHDSXGjqI3yX3UsP0/yqJPOT+O9gtz+/G4lUoD8Kg6 pEpwUfPxgNnt4+JXEFzmK8RPINdc4QZFTtyLQEnoJZYgT9qtWx5GKg6WD7J5o91Tof/R pkqTP4Ym+3dZ/hMbWy8vKsYhl68y53ZJ5Jperk7hZBM5MlCQ1JwkVcldinGcRdQNZo8y zpxlJZwn0n44H1jZ+fyA5jRvzk+LTothOA2kGMG7sGOsWUoJ2gD4YEXcm8HCD4EzP6HE 590w== 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=EEMo9zIgXBYZX6w+vj40KEeWDGQ0HKmPSuSiDY8tumk=; b=6At0BtAJhq84P0h7GnLolb8BNekJgCnDsCH1BX/mGGY22vylp/OVMQQ8denuA1Ktgd k6xWwMNCk1oB4k3DwSYApb4bvNhiHalYV9Kp68KUADwBCeTKy3/1q6bGM6PKdEOjCTsI xIyk8vgY7WYnp26W6qHSjzAq7ovG/+nVFLJB/u4gHKJr3hCVL6y1MWGwHRv5IOMC8zqd 0R7/7cArl/KTNz3wiTqikFsLxRbg7c9D2ch12Ldi9iRnbarzS3ywxQcOXPyHrP/3uRUM u3BzZZnR608UpTEtWxaBYZy+4FjxwrerktyiHW0i4W9mO6vCod4wTPV2L/Kcp/A1tKG4 MYAQ== X-Gm-Message-State: AOAM533DYnNr7UT6cqvyvDzTbXIJj6qDubW+enD06pj9rkblsk7Tp5dj TvIJMrX8ua+YsSjU+gjPZ6+5uZB1dLNN4bC6o/I4piZATRk= X-Google-Smtp-Source: ABdhPJwU2ggeWZ3g9iY8AvDkHjWlj1EXdQAV0G3ZwbTkzRxrfUaw4sWTrOIQ9nSVQUvldQee9CwUpiDX7bCAZ5GaUks= X-Received: by 2002:a05:6808:1825:b0:326:3e14:f156 with SMTP id bh37-20020a056808182500b003263e14f156mr3402152oib.144.1652477961935; Fri, 13 May 2022 14:39:21 -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> <20220512211014.GL7074@brightrain.aerifal.cx> In-Reply-To: <20220512211014.GL7074@brightrain.aerifal.cx> From: Oliver Ford Date: Fri, 13 May 2022 22:39:17 +0100 Message-ID: To: Rich Felker Cc: 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 10:10 PM Rich Felker wrote: > This fails to check that the match is at the start of an option > (preceded by a ',' or at the beginning of string) and fails to > continue if the first match is a false positive (e.g. "ro" in > "symlinkroot,ro"). It's possible to solve this still using strstr in a > loop, but it might be easier to just iterate delimiters and strcmp. > > Also, I'm not sure if hasmntopt is supposed to return a match or not > for something like "uid" in "uid=1001"; if so, being followed by '=' > also needs to be considered valid match. > > Rich Comparing glibc and bionic, they both match when followed by an '='. So the below function handles that, and replaces strstr with an strncmp and a loop. If this version is ok I'll submit a patch? char *hasmntopt(const struct mntent *mnt, const char *opt) { char *ptr = mnt->mnt_opts; size_t len = strlen(opt); while (ptr) { char *end = ptr + len; if (!strncmp(ptr, opt, len) && (*end == '\0' || *end == ',' || *end == '=')) return ptr; ptr = strchr(ptr, ','); if (ptr) ptr++; } return NULL; }