[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] AbortAtLineMatching bug
From: |
Andrew Stribblehill |
Subject: |
[PATCH] AbortAtLineMatching bug |
Date: |
Mon, 19 Jul 2004 15:54:51 +0100 |
User-agent: |
Mutt/1.5.6+20040523i |
The Cfengine program:
------------------------------------------------------------
control:
actionsequence = ( editfiles )
editfiles:
{ /tmp/test
LocateLineMatching "b"
AbortAtLineMatching "b"
LocateLineMatching "c"
ReplaceLineWith "FOO"
}
------------------------------------------------------------
with the input file /tmp/test:
------------------------------------------------------------
a
b
c
d
e
f
------------------------------------------------------------
fails with a segfault around item-ext.c:390. This is because we try
to regfree(rx) though it has never been assigned. My solution (please
confirm that it's correct even for the case where there are buggy
implementations a-la the comments) is as follows:
diff -ruN cfengine-2.1.7p1-old/src/item-ext.c cfengine-2.1.7p1/src/item-ext.c
--- cfengine-2.1.7p1-old/src/item-ext.c 2004-06-23 22:30:52.000000000 +0100
+++ cfengine-2.1.7p1/src/item-ext.c 2004-07-16 15:48:12.000000000 +0100
@@ -381,6 +381,7 @@
continue;
}
+ memcpy(&rx,&rxcache,sizeof(rx)); /* To fix a bug on some implementations
where rx gets emptied */
if (EDABORTMODE && ItemMatchesRegEx(ip->name,VEDITABORT))
{
Verbose("Aborting search, regex %s matches line\n",VEDITABORT);
@@ -388,7 +389,6 @@
return NULL;
}
- memcpy(&rx,&rxcache,sizeof(rx)); /* To fix a bug on some implementations
where rx gets emptied */
if (regexec(&rx,ip->name,1,&pmatch,0) == 0)
{
if ((pmatch.rm_so == 0) && (pmatch.rm_eo == strlen(ip->name)))
--
FAIR ISLE
SOUTHWEST 4 OR 5 BACKING SOUTHEAST 3 OR 4. SHOWERS THEN RAIN.
MODERATE OR GOOD
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] AbortAtLineMatching bug,
Andrew Stribblehill <=