[syslinux] [PATCH 6/6] hdt: fix sizeof(char *) misuse
Geert Stappers
stappers at stappers.nl
Sat May 16 23:16:50 PDT 2015
On Sat, May 16, 2015 at 10:41:40AM -0400, Gene Cumm wrote:
> On Mon, Feb 9, 2015 at 10:01 PM, Jonathan Boeing wrote:
> > The code was passing sizeof(const char *) - not the length of the string
> > or the size of the buffer - as the length to strncmp(). These two cases
> > don't need the length, so switch to strcmp.
>
> Can we trust that the data will not allow strcmp() to compare more
> data than necessary? In other words, can we trust that there will be
> null-terminators?
>
> > Fixes the warning: argument to 'sizeof' in 'strncmp' call is the same
> > expression as the second source; did you mean to provide an explicit
> > length?
> >
> > @@ -211,7 +211,7 @@ cli_mode_t mode_s_to_mode_t(char *name)
> > int i = 0;
> >
> > while (list_modes[i]) {
> > - if (!strncmp(name, list_modes[i]->name, sizeof(list_modes[i]->name)))
> > + if (!strcmp(name, list_modes[i]->name))
> > break;
> > i++;
> > }
Now repeating
Fixes the warning: argument to 'sizeof' in 'strncmp' call is the same
expression as the second source; did you mean to provide an explicit
length?
Groeten
Geert Stappers
Who is happy to see that other patches from Johathan got accepted.
--
Leven en laten leven
More information about the Syslinux
mailing list