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/dot.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/dot.cpp')
-rw-r--r-- | src/dot.cpp | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/dot.cpp b/src/dot.cpp index f9b4302..20dd1e6 100644 --- a/src/dot.cpp +++ b/src/dot.cpp @@ -383,7 +383,7 @@ static bool convertMapFile(FTextStream &t,const char *mapName, while (!f.atEnd()) // foreach line { QCString buf(maxLineLen); - int numBytes = f.readLine(buf.data(),maxLineLen); + int numBytes = f.readLine(buf.rawData(),maxLineLen); buf[numBytes-1]='\0'; if (buf.left(5)=="<area") @@ -733,7 +733,7 @@ static bool checkAndUpdateMd5Signature(const QCString &baseName, { // read checksum QCString md5stored(33); - int bytesRead=f.readBlock(md5stored.data(),32); + int bytesRead=f.readBlock(md5stored.rawData(),32); md5stored[32]='\0'; // compare checksum if (bytesRead==32 && md5==md5stored) @@ -988,7 +988,7 @@ bool DotFilePatcher::run() while (!fi.atEnd()) // foreach line { QCString line(maxLineLen); - int numBytes = fi.readLine(line.data(),maxLineLen); + int numBytes = fi.readLine(line.rawData(),maxLineLen); if (numBytes<=0) { break; @@ -1135,11 +1135,12 @@ bool DotFilePatcher::run() while (!fi.atEnd()) // foreach line { QCString line(maxLineLen); - int numBytes = fi.readLine(line.data(),maxLineLen); + int numBytes = fi.readLine(line.rawData(),maxLineLen); if (numBytes<=0) { break; } + line.resize(numBytes+1); Map *map = m_maps.at(0); // there is only one 'map' for a SVG file t << replaceRef(line,map->relPath,map->urlOnly,map->context,"_top"); } @@ -1964,8 +1965,8 @@ void DotNode::writeXML(FTextStream &t,bool isClassGraph) if (!m_url.isEmpty()) { QCString url(m_url); - char *refPtr = url.data(); - char *urlPtr = strchr(url.data(),'$'); + const char *refPtr = url.data(); + char *urlPtr = strchr(url.rawData(),'$'); if (urlPtr) { *urlPtr++='\0'; @@ -2032,8 +2033,8 @@ void DotNode::writeDocbook(FTextStream &t,bool isClassGraph) if (!m_url.isEmpty()) { QCString url(m_url); - char *refPtr = url.data(); - char *urlPtr = strchr(url.data(),'$'); + const char *refPtr = url.data(); + char *urlPtr = strchr(url.rawData(),'$'); if (urlPtr) { *urlPtr++='\0'; @@ -2105,8 +2106,8 @@ void DotNode::writeDEF(FTextStream &t) if (!m_url.isEmpty()) { QCString url(m_url); - char *refPtr = url.data(); - char *urlPtr = strchr(url.data(),'$'); + const char *refPtr = url.data(); + char *urlPtr = strchr(url.rawData(),'$'); if (urlPtr) { *urlPtr++='\0'; @@ -2300,7 +2301,7 @@ void DotGfxHierarchyTable::createGraph(DotNode *n,FTextStream &out, uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); - MD5SigToString(md5_sig,sigStr.data(),33); + MD5SigToString(md5_sig,sigStr.rawData(),33); bool regenerate=FALSE; if (checkAndUpdateMd5Signature(absBaseName,sigStr) || !checkDeliverables(absImgName,absMapName)) @@ -3028,7 +3029,7 @@ QCString computeMd5Signature(DotNode *root, uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)buf.data(),buf.length(),md5_sig); - MD5SigToString(md5_sig,sigStr.data(),33); + MD5SigToString(md5_sig,sigStr.rawData(),33); if (reNumber) { resetReNumbering(); @@ -3962,7 +3963,7 @@ QCString DotDirDeps::writeGraph(FTextStream &out, uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); - MD5SigToString(md5_sig,sigStr.data(),33); + MD5SigToString(md5_sig,sigStr.rawData(),33); bool regenerate=FALSE; if (checkAndUpdateMd5Signature(absBaseName,sigStr) || !checkDeliverables(graphFormat==GOF_BITMAP ? absImgName : @@ -4108,7 +4109,7 @@ void generateGraphLegend(const char *path) uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); - MD5SigToString(md5_sig,sigStr.data(),33); + MD5SigToString(md5_sig,sigStr.rawData(),33); QCString absBaseName = (QCString)path+"/graph_legend"; QCString absDotName = absBaseName+".dot"; QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT"); @@ -4508,7 +4509,7 @@ QCString DotGroupCollaboration::writeGraph( FTextStream &t, uchar md5_sig[16]; QCString sigStr(33); MD5Buffer((const unsigned char *)theGraph.data(),theGraph.length(),md5_sig); - MD5SigToString(md5_sig,sigStr.data(),33); + MD5SigToString(md5_sig,sigStr.rawData(),33); QCString imgExt = Config_getEnum("DOT_IMAGE_FORMAT"); QCString baseName = m_diskName; QCString imgName = baseName+"."+imgExt; |