On Wed, 2024-08-14 at 11:55 +0900, Jaeyoon Jung (LGE) via 
lists.openembedded.org wrote:
> From: Jaeyoon Jung <[email protected]>
> 
> Use strcmp over strncmp to exact-match uid or gids. Otherwise it may end
> up with returning a wrong id that matches partially.
> 
> Signed-off-by: Jaeyoon Jung <[email protected]>
> ---
>  meta/recipes-devtools/makedevs/makedevs/makedevs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/meta/recipes-devtools/makedevs/makedevs/makedevs.c 
> b/meta/recipes-devtools/makedevs/makedevs/makedevs.c
> index 2254b54891..84b38d2b74 100644
> --- a/meta/recipes-devtools/makedevs/makedevs/makedevs.c
> +++ b/meta/recipes-devtools/makedevs/makedevs/makedevs.c
> @@ -202,7 +202,7 @@ static unsigned long convert2guid(char *id_buf, struct 
> name_id *search_list)
>               // Check for bad user/group name
>               node = search_list;
>               while (node != NULL) {
> -                     if (!strncmp(node->name, id_buf, strlen(id_buf))) {
> +                     if (!strcmp(node->name, id_buf)) {
>                               fprintf(stderr, "WARNING: Bad user/group name 
> %s detected\n", id_buf);
>                               break;
>                       }
> @@ -212,7 +212,7 @@ static unsigned long convert2guid(char *id_buf, struct 
> name_id *search_list)
>       } else {
>               node = search_list;
>               while (node != NULL) {
> -                     if (!strncmp(node->name, id_buf, strlen(id_buf)))
> +                     if (!strcmp(node->name, id_buf))
>                               return node->id;
>                       node = node->next;
>               }

I'm afraid I don't understand the problem here. If partial matching is
occurring, doesn't that mean MAX_ID_LEN is wrong?

If we drop the strncmp() here, that appears to put us at risk of buffer
overflow problems, particularly if MAX_ID_LEN is too short?

Can you give an example of how this is failing and where the above
change helps?

Thanks,

Richard
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#203475): 
https://lists.openembedded.org/g/openembedded-core/message/203475
Mute This Topic: https://lists.openembedded.org/mt/107888859/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to