From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sun, 15 Nov 2020 17:36:34 +0100 Subject: [PATCH v2] env: mmc: Correct partition comparison in mmc_offset_try_partition In-Reply-To: References: <20201112131237.1239-1-jigi.kim@gmail.com> <10748.1605211638@gemini.denx.de> Message-ID: <99094.1605458194@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Hoyeonjiki Kim, In message you wrote: > > As you referred, `strcmp` suffers with non-null terminated string(s). > I'd also checked if using `strcmp` can cause some issues and > seems it's **guaranteed** that there is no such issue in this context. You ar4e probably right, but the problem with this approach is that what today is a verified context, may tomoroow change - a new use case may be added, which is not aware of this potential problem, and which thus triggers a (foreseeable and avoidable bug). > But if we need to specify that the context will not suffer anyway, there > is an option to use `strncmp` with `PART_NAME_LEN` as max count param. > > `PART_NAME_LEN` is the size of `info.name` which is a character buffer. If we know we size (and apparewntly we do), we should use this with strncmp(). Just in case... Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de It's not what you do, it's how you do what you do! - Jordan D. Ulmer