diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2015-01-02 08:56:45 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2015-01-02 09:45:18 (GMT) |
commit | 312bef563a5be72f6423377247db1b80044bf711 (patch) | |
tree | 3a656445fa67469b2f1783932fe127e9f39af69a /src/util.cpp | |
parent | ed39dab59f8af2c5b42cfac0b3140cf594412121 (diff) | |
download | Doxygen-312bef563a5be72f6423377247db1b80044bf711.zip Doxygen-312bef563a5be72f6423377247db1b80044bf711.tar.gz Doxygen-312bef563a5be72f6423377247db1b80044bf711.tar.bz2 |
Fixed a couple of cases where sharing string data could lead to corruption
Also made dangerous string access more visible by introducing rawData().
This replaces data() which will now return a constant string.
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/util.cpp b/src/util.cpp index 000de53..1639e0a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1448,7 +1448,7 @@ static ClassDef *getResolvedClassRec(Definition *scope, // below is a more efficient coding of // QCString key=scope->name()+"+"+name+"+"+explicitScopePart; QCString key(scopeNameLen+nameLen+explicitPartLen+fileScopeLen+1); - char *p=key.data(); + char *p=key.rawData(); qstrcpy(p,scope->name()); *(p+scopeNameLen-1)='+'; p+=scopeNameLen; qstrcpy(p,name); *(p+nameLen-1)='+'; @@ -2379,8 +2379,8 @@ QCString transcodeCharacterStringToUTF8(const QCString &input) { size_t iLeft=inputSize; size_t oLeft=outputSize; - char *inputPtr = input.data(); - char *outputPtr = output.data(); + char *inputPtr = input.rawData(); + char *outputPtr = output.rawData(); if (!portable_iconv(cd, &inputPtr, &iLeft, &outputPtr, &oLeft)) { outputSize-=(int)oLeft; @@ -2418,12 +2418,12 @@ QCString fileToString(const char *name,bool filter,bool isSourceCode) QCString contents(bSize); int totalSize=0; int size; - while ((size=f.readBlock(contents.data()+totalSize,bSize))==bSize) + while ((size=f.readBlock(contents.rawData()+totalSize,bSize))==bSize) { totalSize+=bSize; - contents.resize(totalSize+bSize); + contents.resize(totalSize+bSize); } - totalSize = filterCRLF(contents.data(),totalSize+size)+2; + totalSize = filterCRLF(contents.rawData(),totalSize+size)+2; contents.resize(totalSize); contents.at(totalSize-2)='\n'; // to help the scanner contents.at(totalSize-1)='\0'; @@ -5060,7 +5060,7 @@ QCString substitute(const QCString &s,const QCString &src,const QCString &dst) } QCString result(resLen+1); char *r; - for (r=result.data(), p=s; (q=strstr(p,src))!=0; p=q+srcLen) + for (r=result.rawData(), p=s; (q=strstr(p,src))!=0; p=q+srcLen) { int l = (int)(q-p); memcpy(r,p,l); @@ -5340,7 +5340,7 @@ QCString convertNameToFile(const char *name,bool allowDots,bool allowUnderscore) uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)result.data(),resultLen,md5_sig); - MD5SigToString(md5_sig,sigStr.data(),33); + MD5SigToString(md5_sig,sigStr.rawData(),33); result=result.left(128-32)+sigStr; } } @@ -6550,7 +6550,7 @@ QCString rtfFormatBmkStr(const char *name) g_tagDict.insert( key, tag ); // This is the increment part - char* nxtTag = g_nextTag.data() + g_nextTag.length() - 1; + char* nxtTag = g_nextTag.rawData() + g_nextTag.length() - 1; for ( unsigned int i = 0; i < g_nextTag.length(); ++i, --nxtTag ) { if ( ( ++(*nxtTag) ) > 'Z' ) |