summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2003-02-22 16:33:34 (UTC)
committer zecke <zecke>2003-02-22 16:33:34 (UTC)
commit2424bcd292444b3a03c9b92dbc7f5b392c355755 (patch) (unidiff)
tree7f909f39bce8ba8501d07dc6ff238ae7918fc8de /libopie2
parent66b00525256255290dfcd9d48ebe1539f15b8dce (diff)
downloadopie-2424bcd292444b3a03c9b92dbc7f5b392c355755.zip
opie-2424bcd292444b3a03c9b92dbc7f5b392c355755.tar.gz
opie-2424bcd292444b3a03c9b92dbc7f5b392c355755.tar.bz2
fixx off by one in reading
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp29
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp30
2 files changed, 57 insertions, 2 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index bc51996..24b69fe 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -23,6 +23,33 @@
23#include "odatebookaccessbackend_xml.h" 23#include "odatebookaccessbackend_xml.h"
24 24
25namespace { 25namespace {
26 // FROM TT again
27char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
28{
29 char needleChar;
30 char haystackChar;
31 if (!needle || !haystack || !hLen || !nLen)
32 return 0;
33
34 const char* hsearch = haystack;
35
36 if ((needleChar = *needle++) != 0) {
37 nLen--; //(to make up for needle++)
38 do {
39 do {
40 if ((haystackChar = *hsearch++) == 0)
41 return (0);
42 if (hsearch >= haystack + hLen)
43 return (0);
44 } while (haystackChar != needleChar);
45 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
46 hsearch--;
47 }
48 return ((char *)hsearch);
49}
50}
51
52namespace {
26 time_t start, end, created, rp_end; 53 time_t start, end, created, rp_end;
27 ORecur* rec; 54 ORecur* rec;
28 ORecur* recur() { 55 ORecur* recur() {
@@ -342,7 +369,7 @@ bool ODateBookAccessBackend_XML::loadFile() {
342 const char* collectionString = "<event "; 369 const char* collectionString = "<event ";
343 int strLen = ::strlen(collectionString); 370 int strLen = ::strlen(collectionString);
344 int *find; 371 int *find;
345 while ( dt + 1 != 0 && (( point = ::strstr( dt+i, collectionString ) ) != 0 ) ) { 372 while ( ( point = ::strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0 ) {
346 i = point -dt; 373 i = point -dt;
347 i+= strLen; 374 i+= strLen;
348 375
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 22b2469..cda300b 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -17,6 +17,34 @@
17 17
18#include "otodoaccessxml.h" 18#include "otodoaccessxml.h"
19 19
20namespace {
21 // FROM TT again
22char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
23{
24 char needleChar;
25 char haystackChar;
26 if (!needle || !haystack || !hLen || !nLen)
27 return 0;
28
29 const char* hsearch = haystack;
30
31 if ((needleChar = *needle++) != 0) {
32 nLen--; //(to make up for needle++)
33 do {
34 do {
35 if ((haystackChar = *hsearch++) == 0)
36 return (0);
37 if (hsearch >= haystack + hLen)
38 return (0);
39 } while (haystackChar != needleChar);
40 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
41 hsearch--;
42 }
43 return ((char *)hsearch);
44}
45}
46
47
20OTodoAccessXML::OTodoAccessXML( const QString& appName, 48OTodoAccessXML::OTodoAccessXML( const QString& appName,
21 const QString& fileName ) 49 const QString& fileName )
22 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false ) 50 : OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
@@ -85,7 +113,7 @@ bool OTodoAccessXML::load() {
85 char *point; 113 char *point;
86 const char* collectionString = "<Task "; 114 const char* collectionString = "<Task ";
87 int strLen = strlen(collectionString); 115 int strLen = strlen(collectionString);
88 while ( dt+i != 0 && ( point = strstr( dt+i, collectionString ) ) != 0l ) { 116 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
89 i = point -dt; 117 i = point -dt;
90 i+= strLen; 118 i+= strLen;
91 qWarning("Found a start at %d %d", i, (point-dt) ); 119 qWarning("Found a start at %d %d", i, (point-dt) );