This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[PATCH] Fix comparison between two character arrays
- From: Jordi Sanfeliu <jordi at fibranet dot cat>
- To: newlib at sourceware dot org
- Date: Fri, 27 Jul 2018 11:02:55 +0200 (CEST)
- Subject: [PATCH] Fix comparison between two character arrays
- Dkim-filter: OpenDKIM Filter v2.11.0 mail.fibranet.cat w6R92twX027326
Hello,
The member 'id' in the 'utmp' struct is not a numeric but a character
array, hence the strncmp() function is needed to compare two members.
diff --git a/newlib/libc/unix/getut.c b/newlib/libc/unix/getut.c
index 89ed739..71a8c8f 100644
--- a/newlib/libc/unix/getut.c
+++ b/newlib/libc/unix/getut.c
@@ -63,7 +63,7 @@ getutid (struct utmp *id)
case LOGIN_PROCESS:
case USER_PROCESS:
case DEAD_PROCESS:
- if (id->ut_id == utmp_data.ut_id)
+ if (!strncmp (id->ut_id, utmp_data.ut_id, sizeof (utmp_data.ut_id)))
return &utmp_data;
break;
default:
Thanks.
--
Jordi Sanfeliu
FIBRANET Network Services Provider
https://www.fibranet.cat