[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
user/962: m4 STREQ broken
>Number: 962
>Category: user
>Synopsis: STREQ in m4 is seriously broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bugs
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Nov 2 10:00:01 MST 1999
>Last-Modified:
>Originator: Claus Assmann
>Organization:
endmail.ORG
>Release: OpenBSD 2.6
>Environment:
System : OpenBSD 2.6
Architecture: OpenBSD.i386
Machine : i386
>Description:
the definition of STREQ in m4/stdd.h is seriously broken!
it accesses empty strings after their end.
>How-To-Repeat:
create t.m4 with content:
ifelse(`', `', `OK',`WRONG')
then run m4 t.m4
>Fix:
--- stdd.h Tue Nov 2 08:47:43 1999
+++ /usr/src/usr.bin/m4/stdd.h Wed Sep 22 14:44:38 1999
@@ -52,7 +52,7 @@
* STREQ is an optimised strcmp(a,b)==0
* STREQN is an optimised strncmp(a,b,n)==0; assumes n > 0
*/
-#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp((a), (b)) == 0)
+#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp((a)+1, (b)+1) == 0)
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp((a)+1, (b)+1, (n)-1) == 0)
#define YES 1
>Audit-Trail:
>Unformatted: