public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Tom spot Callaway <spotaws@amazon.com>
To: git-commits@fedoraproject.org
Subject: [rpms/libdxfrw] rawhide: apply more fixes from the 2.2.1 LibreCAD git tree
Date: Tue, 24 Nov 2026 22:37:55 GMT	[thread overview]
Message-ID: <179555987596.1.5672020969992060417.rpms-libdxfrw-f58e6ebce060@fedoraproject.org> (raw)

A new commit has been pushed.

Repo   : rpms/libdxfrw
Branch : rawhide
Commit : f58e6ebce060ae3a5b874d8490d127f46c980c6f
Author : Tom spot Callaway <spotaws@amazon.com>
Date   : 2026-11-24T17:37:49-05:00
Stats  : +603/-51 in 10 file(s)
URL    : https://src.fedoraproject.org/rpms/libdxfrw/c/f58e6ebce060ae3a5b874d8490d127f46c980c6f?branch=rawhide

Log:
apply more fixes from the 2.2.1 LibreCAD git tree

---
diff --git a/03fa108ab2fd74ab7b070daf5b36b29eb0428536.patch b/03fa108ab2fd74ab7b070daf5b36b29eb0428536.patch
new file mode 100644
index 0000000..0ded35f
--- /dev/null
+++ b/03fa108ab2fd74ab7b070daf5b36b29eb0428536.patch
@@ -0,0 +1,20 @@
+--- a/src/drw_entities.cpp
++++ b/src/drw_entities.cpp
+@@ -1105,7 +1105,7 @@ bool DRW_Insert::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
+             attH = buf->getHandle(); /* H 2 BLOCK HEADER (hard pointer) */
+             DRW_DBG("second attrib Handle: "); DRW_DBGHL(attH.code, attH.size, attH.ref); DRW_DBG("\n");
+         } else {
+-            for (dint32 i=0; i< objCount; ++i){
++            for (dint32 i=0; i< objCount && buf->isGood(); ++i){
+                 dwgHandle attH = buf->getHandle(); /* H 2 BLOCK HEADER (hard pointer) */
+                 DRW_DBG("attrib Handle #"); DRW_DBG(i); DRW_DBG(": "); DRW_DBGHL(attH.code, attH.size, attH.ref); DRW_DBG("\n");
+             }
+@@ -2990,7 +2990,7 @@ bool DRW_Viewport::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
+         DRW_DBG("ViewPort ent header: "); DRW_DBGHL(someHdl.code, someHdl.size, someHdl.ref); DRW_DBG("\n");
+     }
+     if (version > DRW::AC1014) {//2000+
+-        for (duint32 i=0; i < frozenLyCount; ++i){
++        for (duint32 i=0; i < frozenLyCount && buf->isGood(); ++i){
+             someHdl = buf->getHandle();
+             DRW_DBG("Frozen layer handle "); DRW_DBG(i); DRW_DBG(": "); DRW_DBGHL(someHdl.code, someHdl.size, someHdl.ref); DRW_DBG("\n");
+         }

diff --git a/17ba2b273b89cc9c8b6fcf71882e327ccf1eebf6.patch b/17ba2b273b89cc9c8b6fcf71882e327ccf1eebf6.patch
new file mode 100644
index 0000000..5a75c11
--- /dev/null
+++ b/17ba2b273b89cc9c8b6fcf71882e327ccf1eebf6.patch
@@ -0,0 +1,99 @@
+--- a/src/intern/dwgreader18.cpp
++++ b/src/intern/dwgreader18.cpp
+@@ -13,6 +13,8 @@
+ #include <cstdlib>
+ #include <iostream>
+ #include <fstream>
++#include <new>
++#include <utility>
+ #include <string>
+ #include <sstream>
+ #include <vector>
+@@ -111,15 +113,39 @@ bool dwgReader18::parseSysPage(duint8 *decompSec, duint32 decompSize){
+  //called ???: Section map: 0x4163003b
+ bool dwgReader18::parseDataPage(const dwgSectionInfo &si/*, duint8 *dData*/){
+     DRW_DBG("\nparseDataPage\n ");
+-    objData.reset( new duint8 [si.pageCount * si.maxSize] );
++    constexpr duint64 maxBufferSize = 0x2f000000;
++    const duint64 pageCap = si.maxSize != 0 ? si.maxSize : si.size;
++    if (si.size == 0 || (si.compressed != 1 && si.compressed != 2)
++        || pageCap == 0)
++        return false;
++
++    duint64 bufferPageCount =
++        si.size / pageCap + (si.size % pageCap != 0);
++    if (bufferPageCount < si.pageCount)
++        bufferPageCount = si.pageCount;
++    if (bufferPageCount > maxBufferSize / pageCap)
++        return false;
++
++    const duint64 bufferSize = bufferPageCount * pageCap;
++    std::unique_ptr<duint8[]> decodedData(new (std::nothrow)
++        duint8[static_cast<std::size_t>(bufferSize)]());
++    if (!decodedData)
++        return false;
+ 
+     for (auto it=si.pages.begin(); it!=si.pages.end(); ++it){
+         dwgPageInfo pi = it->second;
++        const duint64 fileSize = fileBuf->size();
++        if (pi.size < 32 || pi.address > fileSize
++            || pi.size > fileSize - pi.address
++            || pi.startOffset > bufferSize
++            || pageCap > bufferSize - pi.startOffset)
++            return false;
+         if (!fileBuf->setPosition(pi.address))
+             return false;
+         //decript section header
+         duint8 hdrData[32];
+-        fileBuf->getBytes(hdrData, 32);
++        if (!fileBuf->getBytes(hdrData, 32))
++            return false;
+         dwgCompressor::decrypt18Hdr(hdrData, 32, pi.address);
+         DRW_DBG("Section  "); DRW_DBG(si.name); DRW_DBG(" page header=\n");
+         for (unsigned int i=0, j=0; i< 32;i++) {
+@@ -150,29 +176,36 @@ bool dwgReader18::parseDataPage(const dwgSectionInfo &si/*, duint8 *dData*/){
+         DRW_DBG("\n      header checksum= "); DRW_DBGH(bufHdr.getRawLong32());
+         DRW_DBG("\n      data checksum= "); DRW_DBGH(bufHdr.getRawLong32()); DRW_DBG("\n");
+ 
++        if (!bufHdr.isGood() || pi.cSize == 0
++            || pi.cSize > pi.size - 32 || pi.cSize > maxBufferSize
++            || pi.uSize > pageCap)
++            return false;
++
+         //get compressed data
+-        std::vector<duint8> cData(pi.cSize);
+-        if (!fileBuf->setPosition(pi.address + 32)) {
++        std::unique_ptr<duint8[]> cData(new (std::nothrow)
++            duint8[static_cast<std::size_t>(pi.cSize)]);
++        if (!cData || !fileBuf->setPosition(pi.address + 32)
++            || !fileBuf->getBytes(cData.get(), pi.cSize))
+             return false;
+-        }
+-        fileBuf->getBytes(cData.data(), pi.cSize);
+ 
+         //calculate checksum
+-        duint32 calcsD = checksum(0, cData.data(), pi.cSize);
++        duint32 calcsD = checksum(0, cData.get(), pi.cSize);
+         for (duint8 i= 24; i<28; ++i)
+             hdrData[i]=0;
+         duint32 calcsH = checksum(calcsD, hdrData, 32);
+         DRW_DBG("Calc header checksum= "); DRW_DBGH(calcsH);
+         DRW_DBG("\nCalc data checksum= "); DRW_DBGH(calcsD); DRW_DBG("\n");
+ 
+-        duint8* oData = objData.get() + pi.startOffset;
+-        pi.uSize = si.maxSize;
+-        DRW_DBG("decompressing "); DRW_DBG(pi.cSize); DRW_DBG(" bytes in "); DRW_DBG(pi.uSize); DRW_DBG(" bytes\n");
++        duint8* oData = decodedData.get()
++            + static_cast<std::size_t>(pi.startOffset);
++        DRW_DBG("decompressing "); DRW_DBG(pi.cSize);
++        DRW_DBG(" bytes in "); DRW_DBG(pageCap); DRW_DBG(" bytes\n");
+         dwgCompressor comp;
+-        if (!comp.decompress18(cData.data(), oData, pi.cSize, pi.uSize)) {
++        if (!comp.decompress18(cData.get(), oData, pi.cSize, pageCap)) {
+             return false;
+         }
+     }
++    objData = std::move(decodedData);
+     return true;
+ }
+ 

diff --git a/1a8202f1dc39c52d20ca49e697de9cc2c2d4fb0c.patch b/1a8202f1dc39c52d20ca49e697de9cc2c2d4fb0c.patch
new file mode 100644
index 0000000..e2ec4b2
--- /dev/null
+++ b/1a8202f1dc39c52d20ca49e697de9cc2c2d4fb0c.patch
@@ -0,0 +1,61 @@
+--- a/src/drw_entities.cpp
++++ b/src/drw_entities.cpp
+@@ -1470,9 +1470,12 @@ bool DRW_MText::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
+     }
+     height = buf->getBitDouble();/* Text height BD 40 Undocumented */
+     textgen = buf->getBitShort(); /* Attachment BS 71 Similar to justification; */
+-    /* Drawing dir BS 72 Left to right, etc.; see DXF doc */
+-    dint16 draw_dir = buf->getBitShort();
+-    DRW_UNUSED(draw_dir);
++    /* Drawing dir BS 72 Left to right, etc.; see DXF doc. Reuse the
++     * inherited alignH slot — for MTEXT this field carries the DXF group 72
++     * "drawing direction" code (1=LtoR, 3=TtoB, 5=ByStyle), not the TEXT
++     * horizontal-alignment values the HAlign enum was named for. The integer
++     * round-trips cleanly; consumers compare against the raw integer. */
++    alignH = static_cast<HAlign>(buf->getBitShort());
+     /* Extents ht BD Undocumented and not present in DXF or entget */
+     double ext_ht = buf->getBitDouble();
+     DRW_UNUSED(ext_ht);
+--- a/src/libdxfrw.cpp
++++ b/src/libdxfrw.cpp
+@@ -1273,6 +1273,9 @@ bool dxfRW::writeMText(DRW_MText *ent){
+         writer->writeInt16(73, ent->alignV);
+         writer->writeDouble(44, ent->interlin);
+ //RLZ ... 11, 21, 31 needed?
++        if (!ent->extData.empty()) {
++            writeExtData(ent->extData);
++        }
+     } else {
+         //RLZ: TODO convert mtext in text lines (not exist in acad 12)
+     }
+@@ -1828,6 +1831,18 @@ bool dxfRW::writeObjects() {
+     return true;
+ }
+ 
++bool dxfRW::writeExtData(
++    const std::vector<std::shared_ptr<DRW_Variant>> &ed) {
++    // Re-pack as raw pointers so we share the existing implementation. The
++    // raw pointers do not own — same lifetime as the shared_ptrs in @p ed.
++    std::vector<DRW_Variant*> raw;
++    raw.reserve(ed.size());
++    for (const auto &sp : ed) {
++        if (sp) raw.push_back(sp.get());
++    }
++    return writeExtData(raw);
++}
++
+ bool dxfRW::writeExtData(const std::vector<DRW_Variant*> &ed){
+     for (std::vector<DRW_Variant*>::const_iterator it=ed.begin(); it!=ed.end(); ++it){
+         switch ((*it)->code()) {
+--- libdxfrw/src/libdxfrw.h
++++ libdxfrw/src/libdxfrw.h
+@@ -125,6 +125,9 @@ class dxfRW {
+     bool writeBlocks();
+     bool writeObjects();
+     bool writeExtData(const std::vector<DRW_Variant*> &ed);
++    /* Entity-flavoured overload: entities own extData via shared_ptr, table
++     * records own raw pointers. Same DXF codes, different storage. */
++    bool writeExtData(const std::vector<std::shared_ptr<DRW_Variant>> &ed);
+     /*use version from dwgutil.h*/
+     std::string toHexStr(int n);//RLZ removeme
+     bool writeAppData(const std::list<std::list<DRW_Variant>> &appData);

diff --git a/1eeda16c23f738fd934d467e90582f86e4d77794.patch b/1eeda16c23f738fd934d467e90582f86e4d77794.patch
new file mode 100644
index 0000000..dab1e20
--- /dev/null
+++ b/1eeda16c23f738fd934d467e90582f86e4d77794.patch
@@ -0,0 +1,21 @@
+--- a/src/drw_entities.cpp
++++ b/src/drw_entities.cpp
+@@ -2173,11 +2173,17 @@ bool DRW_Spline::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
+     if (!DRW::reserve( controllist, ncontrol)) {
+         return false;
+     }
++    if (weight && !DRW::reserve( weightlist, ncontrol)) {
++        return false;
++    }
+     for (dint32 i= 0; i<ncontrol; ++i){
+         controllist.push_back(std::make_shared<DRW_Coord>(buf->get3BitDouble()));
+         if (weight) {
++            // kept, as the DXF reader keeps code 41: a rational spline such as
++            // a hyperbola arc is a different curve without its weights
++            weightlist.push_back(buf->getBitDouble()); //RLZ Warning: D (BD or RD)
+             DRW_DBG("\n w: ");
+-            DRW_DBG(buf->getBitDouble()); //RLZ Warning: D (BD or RD)
++            DRW_DBG(weightlist.back());
+         }
+     }
+     if (!DRW::reserve( fitlist, nfit)) {

diff --git a/8477afa53995841d84d209eaa3516c98e3830052.patch b/8477afa53995841d84d209eaa3516c98e3830052.patch
new file mode 100644
index 0000000..c6a3fa3
--- /dev/null
+++ b/8477afa53995841d84d209eaa3516c98e3830052.patch
@@ -0,0 +1,85 @@
+--- a/src/drw_header.cpp
++++ b/src/drw_header.cpp
+@@ -20,6 +20,7 @@
+ DRW_Header::DRW_Header() {
+     linetypeCtrl = layerCtrl = styleCtrl = dimstyleCtrl = appidCtrl = 0;
+     blockCtrl = viewCtrl = ucsCtrl = vportCtrl = vpEntHeaderCtrl = 0;
++    clayerHandle = 0;
+     version = DRW::AC1021;
+ }
+ 
+@@ -1949,6 +1950,7 @@ bool DRW_Header::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer *hBbuf
+     DRW_DBG("\nHANDSEED: "); DRW_DBGHL(HANDSEED.code, HANDSEED.size, HANDSEED.ref);
+     dwgHandle CLAYER = hBbuf->getHandle();
+     DRW_DBG("\nCLAYER: "); DRW_DBGHL(CLAYER.code, CLAYER.size, CLAYER.ref);
++    clayerHandle = CLAYER.ref;
+     dwgHandle TEXTSTYLE = hBbuf->getHandle();
+     DRW_DBG("\nTEXTSTYLE: "); DRW_DBGHL(TEXTSTYLE.code, TEXTSTYLE.size, TEXTSTYLE.ref);
+     dwgHandle CELTYPE = hBbuf->getHandle();
+diff --git a/libraries/libdxfrw/src/drw_header.h b/libraries/libdxfrw/src/drw_header.h
+index d6da9154e2..2dd01bb16e 100644
+--- a/src/drw_header.h
++++ b/src/drw_header.h
+@@ -131,6 +131,9 @@ class DRW_Header {
+     duint32 ucsCtrl;
+     duint32 vportCtrl;
+     duint32 vpEntHeaderCtrl;
++    /// DWG CLAYER, the current layer by handle. parseDwg captures it, and the
++    /// DWG reader turns it into the "$CLAYER" name once the LAYER table is read.
++    duint32 clayerHandle;
+ 
+     int measurement(const int unit);
+ };
+diff --git a/libraries/libdxfrw/src/drw_objects.cpp b/libraries/libdxfrw/src/drw_objects.cpp
+index 80703edab3..9a8028a15b 100644
+--- a/src/drw_objects.cpp
++++ b/src/drw_objects.cpp
+@@ -643,22 +643,26 @@ bool DRW_Layer::parseDwg(DRW::Version version, dwgBuffer *buf, duint32 bs){
+         //dint16 xrefindex = buf->getBitShort();
+     }
+     flags |= buf->getBit() << 4;//is refx dependent
++    bool layerOff = false;
+     if (version < DRW::AC1015) {//14-
+         flags |= buf->getBit(); //layer frozen
+-        /*flags |=*/ buf->getBit(); //unused, negate the color
++        layerOff = buf->getBit() != 0; //layer off: a negative colour, as in DXF
+         flags |= buf->getBit() << 1;//frozen in new
+-        flags |= buf->getBit()<< 3;//locked
++        flags |= buf->getBit()<< 2;//locked, DXF code 70 bit 4
+     }
+     if (version > DRW::AC1014) {//2000+
+         dint16 f = buf->getSBitShort();//bit2 are layer on
+         DRW_DBG(", flags 2000+: "); DRW_DBG(f); DRW_DBG("\n");
+         flags |= f & 0x0001; //layer frozen
++        layerOff = (f & 0x0002) != 0; //bit 2 is "layer on" in the specification, and is read as off, as the ODA File Converter writes it
+         flags |= ( f>> 1) & 0x0002;//frozen in new
+         flags |= ( f>> 1) & 0x0004;//locked
+         plotF = ( f>> 4) & 0x0001;
+         lWeight = DRW_LW_Conv::dwgInt2lineWidth( (f & 0x03E0) >> 5 );
+     }
+-    color = buf->getCmColor(version); //BS or CMC //ok for R14 or negate
++    color = buf->getCmColor(version); //BS or CMC
++    if (layerOff && color > 0)
++        color = -color;
+     DRW_DBG(", entity color: "); DRW_DBG(color); DRW_DBG("\n");
+ 
+     if (version > DRW::AC1018) {//2007+ skip string area
+diff --git a/libraries/libdxfrw/src/intern/dwgreader.cpp b/libraries/libdxfrw/src/intern/dwgreader.cpp
+index c704bcc8ab..a35178926a 100644
+--- a/src/intern/dwgreader.cpp
++++ b/src/intern/dwgreader.cpp
+@@ -309,6 +309,14 @@ bool dwgReader::readDwgTables(DRW_Header& hdr, dwgBuffer *dbuf) {
+         }
+     }
+ 
++    // the header names the current layer by handle (CLAYER): give it by name,
++    // as the DXF header does ($CLAYER)
++    {
++        auto cl = layermap.find(hdr.clayerHandle);
++        if (cl != layermap.end())
++            hdr.addStr("$CLAYER", cl->second->name, 8);
++    }
++
+     //parse text styles, start with style Control
+     mit = ObjectMap.find(hdr.styleCtrl);
+     if (mit==ObjectMap.end()) {

diff --git a/a536057a928aa051b6339d51f6764ff5c386c92f.patch b/a536057a928aa051b6339d51f6764ff5c386c92f.patch
new file mode 100644
index 0000000..f3d0b07
--- /dev/null
+++ b/a536057a928aa051b6339d51f6764ff5c386c92f.patch
@@ -0,0 +1,48 @@
+--- a/src/intern/dwgreader.h
++++ b/src/intern/dwgreader.h
+@@ -60,13 +60,13 @@ class dwgPageInfo {
+     dwgPageInfo(duint64 i, duint64 ad, duint64 sz){
+         Id=i; address=ad; size=sz;
+     }
+-    duint64 Id;
+-    duint64 address; //in file stream, for rd18, rd21
+-    duint64 size; //in file stream, for rd18, rd21
+-    duint64 dataSize; //for rd18, rd21
+-    duint64 startOffset; //for rd18, rd21
+-    duint64 cSize; //compressed page size, for rd21
+-    duint64 uSize; //uncompressed page size, for rd21
++    duint64 Id{0};
++    duint64 address{0}; //in file stream, for rd18, rd21
++    duint64 size{0}; //in file stream, for rd18, rd21
++    duint64 dataSize{0}; //for rd18, rd21
++    duint64 startOffset{0}; //for rd18, rd21
++    duint64 cSize{0}; //compressed page size, for rd21
++    duint64 uSize{0}; //uncompressed page size, for rd21
+ };
+ 
+ // sections of file
+@@ -88,10 +88,10 @@ class dwgSectionInfo {
+     duint32 compressed{1};//is compressed? 1=no, 2=yes rd18, rd21(encoding)
+     duint32 encrypted{0};//encrypted (doc: 0=no, 1=yes, 2=unkn) on read: objects 0 and encrypted yes rd18
+     std::unordered_map<duint32, dwgPageInfo >pages;//index, size, offset
+-    duint64 size;//size of section,  2000- rd15, rd18, rd21 (data size)
++    duint64 size{0};//size of section,  2000- rd15, rd18, rd21 (data size)
+     duint64 pageCount{0}; //number of pages (dwgPageInfo) in section rd18, rd21
+-    duint64 maxSize; //max decompressed size (needed??) rd18 rd21
+-    duint64 address; //address (seek) , 2000-
++    duint64 maxSize{0}; //max decompressed size (needed??) rd18 rd21
++    duint64 address{0}; //address (seek) , 2000-
+ };
+ 
+ 
+--- a/src/libdxfrw.cpp
++++ b/src/libdxfrw.cpp
+@@ -77,7 +77,7 @@ bool dxfRW::read(DRW_Interface *interface_, bool ext){
+         return setError(DRW::BAD_OPEN);
+     }
+ 
+-    char line[22];
++    char line[22] = {};
+     char line2[22] = "AutoCAD Binary DXF\r\n";
+     line2[20] = (char)26;
+     line2[21] = '\0';

diff --git a/d11a8d909ede733aa5fa3b20da17bbb5aeb2f21e.patch b/d11a8d909ede733aa5fa3b20da17bbb5aeb2f21e.patch
new file mode 100644
index 0000000..6f38846
--- /dev/null
+++ b/d11a8d909ede733aa5fa3b20da17bbb5aeb2f21e.patch
@@ -0,0 +1,167 @@
+--- a/src/intern/dwgbuffer.cpp
++++ b/src/intern/dwgbuffer.cpp
+@@ -347,15 +347,16 @@ double dwgBuffer::getBitDouble(){
+     if (b == 1)
+         return 1.0;
+     else if (b == 0){
+-        duint8 buffer[8];
++        duint8 buffer[8] = {};
+         if (bitPos != 0) {
+             for (int i = 0; i < 8; i++)
+                 buffer[i] = getRawChar8();
+         } else {
+         filestr->read (buffer,8);
+         }
+-        double* ret = reinterpret_cast<double*>( buffer );
+-        return *ret;
++        double ret = 0.;
++        memcpy(&ret, buffer, sizeof(ret));
++        return ret;
+     }
+     //    if (b == 2)
+     return 0.0;
+@@ -416,8 +417,9 @@ double dwgBuffer::getRawDouble(){
+         for (int i = 0; i < 8; i++)
+             buffer[i] = getRawChar8();
+     }
+-    double* nOffset = reinterpret_cast<double*>( buffer );
+-    return *nOffset;
++    double ret = 0.;
++    memcpy(&ret, buffer, sizeof(ret));
++    return ret;
+ }
+ 
+ /**Reads 2 raw double IEEE standard 64 bits returns a DRW_Coord of floating point double 64 bits (2RD) **/
+@@ -822,7 +824,7 @@ duint32 dwgBuffer::getEnColor(DRW::Version v) {
+ 
+ /**Reads raw short 16 bits big-endian order, returns a unsigned short crc & size **/
+ duint16 dwgBuffer::getBERawShort16(){
+-    char buffer[2];
++    duint8 buffer[2];
+     buffer[0] = getRawChar8();
+     buffer[1] = getRawChar8();
+     duint16 size = (buffer[0] << 8) | (buffer[1] & 0xFF);
+diff --git a/libraries/libdxfrw/src/intern/dwgutil.cpp b/libraries/libdxfrw/src/intern/dwgutil.cpp
+index 5292815588..dc3620f978 100644
+--- a/src/intern/dwgutil.cpp
++++ b/src/intern/dwgutil.cpp
+@@ -10,6 +10,7 @@
+ **  along with this program.  If not, see <http://www.gnu.org/licenses/>.    **
+ ******************************************************************************/
+ 
++#include <cstring>
+ #include <sstream>
+ #include "drw_dbg.h"
+ #include "dwgutil.h"
+@@ -297,9 +298,12 @@ bool dwgCompressor::buffersGood(void)
+ void dwgCompressor::decrypt18Hdr(duint8 *buf, duint64 size, duint64 offset){
+     duint8 max = size / 4;
+     duint32 secMask = 0x4164536b ^ offset;
+-    duint32* pHdr = reinterpret_cast<duint32*>(buf);
+-    for (duint8 j = 0; j < max; j++)
+-        *pHdr++ ^= secMask;
++    for (duint8 j = 0; j < max; j++) {
++        duint32 word = 0;
++        memcpy(&word, buf + 4*j, sizeof(word));
++        word ^= secMask;
++        memcpy(buf + 4*j, &word, sizeof(word));
++    }
+ }
+ 
+ /*void dwgCompressor::decrypt18Data(duint8 *buf, duint32 size, duint32 offset){
+diff --git a/libraries/libdxfrw/src/intern/dxfreader.cpp b/libraries/libdxfrw/src/intern/dxfreader.cpp
+index 94f48516e8..289e7e437a 100644
+--- a/src/intern/dxfreader.cpp
++++ b/src/intern/dxfreader.cpp
+@@ -10,6 +10,7 @@
+ **  along with this program.  If not, see <http://www.gnu.org/licenses/>.    **
+ ******************************************************************************/
+ 
++#include <cstdint>
+ #include <cstdlib>
+ #include <fstream>
+ #include <string>
+@@ -112,18 +113,15 @@ int dxfReader::getHandleString(){
+ }
+ 
+ bool dxfReaderBinary::readCode(int *code) {
+-    unsigned short *int16p;
+-    char buffer[2];
+-    filestr->read(buffer,2);
+-    int16p = (unsigned short *) buffer;
++    std::uint16_t value = 0;
++    filestr->read(reinterpret_cast<char*>(&value),2);
+ //exist a 32bits int (code 90) with 2 bytes???
+-    if ((*code == 90) && (*int16p>2000)){
++    if ((*code == 90) && (value>2000)){
+         DRW_DBG(*code); DRW_DBG(" de 16bits\n");
+         filestr->seekg(-4, std::ios_base::cur);
+-        filestr->read(buffer,2);
+-        int16p = (unsigned short *) buffer;
++        filestr->read(reinterpret_cast<char*>(&value),2);
+     }
+-    *code = *int16p;
++    *code = value;
+     DRW_DBG(*code); DRW_DBG("\n");
+ 
+     return (filestr->good());
+@@ -155,49 +153,40 @@ bool dxfReaderBinary::readBinary() {
+ 
+ bool dxfReaderBinary::readInt16() {
+     type = INT32;
+-    char buffer[2];
+-    filestr->read(buffer,2);
+-    intData = (int)((buffer[1] << 8) | buffer[0]);
++    unsigned char buffer[2] = {};
++    filestr->read(reinterpret_cast<char*>(buffer),2);
++    intData = static_cast<std::int16_t>(buffer[1] << 8 | buffer[0]);
+     DRW_DBG(intData); DRW_DBG("\n");
+     return (filestr->good());
+ }
+ 
+ bool dxfReaderBinary::readInt32() {
+     type = INT32;
+-    unsigned int *int32p;
+-    char buffer[4];
+-    filestr->read(buffer,4);
+-    int32p = (unsigned int *) buffer;
+-    intData = *int32p;
++    intData = 0;
++    filestr->read(reinterpret_cast<char*>(&intData),4);
+     DRW_DBG(intData); DRW_DBG("\n");
+     return (filestr->good());
+ }
+ 
+ bool dxfReaderBinary::readInt64() {
+     type = INT64;
+-    unsigned long long int *int64p; //64 bits integer pointer
+-    char buffer[8];
+-    filestr->read(buffer,8);
+-    int64p = (unsigned long long int *) buffer;
+-    int64 = *int64p;
++    int64 = 0;
++    filestr->read(reinterpret_cast<char*>(&int64),8);
+     DRW_DBG(int64); DRW_DBG(" int64\n");
+     return (filestr->good());
+ }
+ 
+ bool dxfReaderBinary::readDouble() {
+     type = DOUBLE;
+-    double *result;
+-    char buffer[8];
+-    filestr->read(buffer,8);
+-    result = (double *) buffer;
+-    doubleData = *result;
++    doubleData = 0.;
++    filestr->read(reinterpret_cast<char*>(&doubleData),8);
+     DRW_DBG(doubleData); DRW_DBG("\n");
+     return (filestr->good());
+ }
+ 
+ //saved as int or add a bool member??
+ bool dxfReaderBinary::readBool() {
+-    char buffer[1];
++    char buffer[1] = {};
+     filestr->read(buffer,1);
+     intData = (int)(buffer[0]);
+     DRW_DBG(intData); DRW_DBG("\n");

diff --git a/fb40d56d42d96866af25aed56b1f60a627e43a49.patch b/fb40d56d42d96866af25aed56b1f60a627e43a49.patch
new file mode 100644
index 0000000..23f71b7
--- /dev/null
+++ b/fb40d56d42d96866af25aed56b1f60a627e43a49.patch
@@ -0,0 +1,33 @@
+--- a/src/drw_entities.cpp
++++ b/src/drw_entities.cpp
+@@ -91,7 +91,7 @@ bool DRW_Entity::parseCode(int code, dxfReader *reader){
+         ltypeScale = reader->getDouble();
+         break;
+     case 60:
+-        visible = reader->getBool();
++        visible = reader->getInt32() == 0;
+         break;
+     case 420:
+         color24 = reader->getInt32();
+@@ -358,6 +358,7 @@ bool DRW_Entity::parseDwg(DRW::Version version, dwgBuffer *buf, dwgBuffer* strBu
+     }
+     dint16 invisibleFlag = buf->getBitShort(); //BS
+     DRW_DBG(" invisibleFlag: "); DRW_DBG(invisibleFlag);
++    visible = (invisibleFlag & 1) == 0;
+     if (version > DRW::AC1014) {//2000+
+         lWeight = DRW_LW_Conv::dwgInt2lineWidth( buf->getRawChar8() ); //RC
+         DRW_DBG(" lwFlag (lWeight): "); DRW_DBG(lWeight); DRW_DBG("\n");
+diff --git a/libraries/libdxfrw/src/libdxfrw.cpp b/libraries/libdxfrw/src/libdxfrw.cpp
+index 789af76efd..64bb895b31 100644
+--- a/src/libdxfrw.cpp
++++ b/src/libdxfrw.cpp
+@@ -186,6 +186,9 @@ bool dxfRW::writeEntity(DRW_Entity *ent) {
+     if (version > DRW::AC1014) {
+         writer->writeInt16(370, DRW_LW_Conv::lineWidth2dxfInt(ent->lWeight));
+     }
++    if (!ent->visible) {
++        writer->writeInt16(60, 1);
++    }
+     if (version >= DRW::AC1014) {
+         writeAppData(ent->appData);
+     }

diff --git a/libdxfrw-dwgbuffer-uninit.patch b/libdxfrw-dwgbuffer-uninit.patch
new file mode 100644
index 0000000..c9dc740
--- /dev/null
+++ b/libdxfrw-dwgbuffer-uninit.patch
@@ -0,0 +1,38 @@
+--- a/src/intern/dwgbuffer.cpp
++++ b/src/intern/dwgbuffer.cpp
+@@ -194,7 +194,7 @@
+     if (pos>7)
+         return;
+     if (pos != 0 && bitPos == 0){
+-        duint8 buffer;
++        duint8 buffer = 0;
+         filestr->read (&buffer,1);
+         currByte = buffer;
+     }
+@@ -219,7 +219,7 @@
+ 
+ /**Reads one Bit returns a char with value 0/1 (B) **/
+ duint8 dwgBuffer::getBit(){
+-    duint8 buffer;
++    duint8 buffer = 0;
+     duint8 ret = 0;
+     if (bitPos == 0){
+         filestr->read (&buffer,1);
+@@ -241,7 +241,7 @@
+ 
+ /**Reads two Bits returns a char (BB) **/
+ duint8 dwgBuffer::get2Bits(){
+-    duint8 buffer;
++    duint8 buffer = 0;
+     duint8 ret = 0;
+     if (bitPos == 0){
+         filestr->read (&buffer,1);
+@@ -267,7 +267,7 @@
+ /**Reads thee Bits returns a char (3B) **/
+ //RLZ: todo verify this
+ duint8 dwgBuffer::get3Bits(){
+-    duint8 buffer;
++    duint8 buffer = 0;
+     duint8 ret = 0;
+     if (bitPos == 0){
+         filestr->read (&buffer,1);

diff --git a/libdxfrw.spec b/libdxfrw.spec
index 74e77f6..285d7d2 100644
--- a/libdxfrw.spec
+++ b/libdxfrw.spec
@@ -5,7 +5,7 @@
 
 Name:		libdxfrw
 Version:	1.1.0
-Release:	0.13.rc1%{?dist}
+Release:	0.14.rc1%{?dist}
 Summary:	Library to read/write DXF files
 # Automatically converted from old format: GPLv2+ - review is highly recommended.
 License:	GPL-2.0-or-later
@@ -50,44 +50,26 @@ Patch9:		4dc3d5fa4b328873af07be05d7b67e5846628eb7.patch
 # Header cleanup
 # https://github.com/LibreCAD/LibreCAD/commit/1603a1ac5ef804b50b8fb583662c0bdcbf9ec72c
 Patch10:	1603a1ac5ef804b50b8fb583662c0bdcbf9ec72c.patch
+# MText: RTL bidi support backport
+Patch11:	1a8202f1dc39c52d20ca49e697de9cc2c2d4fb0c.patch
+# drw_entities: static analysis fixes
+Patch12:	03fa108ab2fd74ab7b070daf5b36b29eb0428536.patch
+# Backport a bounded hyperbola entity, drawing action and spline conversion
+Patch13:	1eeda16c23f738fd934d467e90582f86e4d77794.patch
+# 2.2.1: preserve entity visibility independently of frozen layers
+Patch14:	fb40d56d42d96866af25aed56b1f60a627e43a49.patch
+# 2.2.1: Fix undefined behavior found with sanitizers
+Patch15:	d11a8d909ede733aa5fa3b20da17bbb5aeb2f21e.patch
+# 2.2.1: Fix defects identified by static analysis
+Patch16:	a536057a928aa051b6339d51f6764ff5c386c92f.patch
+# 2.2.1: Let a hidden layer be current, and open DWG/DXF layers with their lock, current layer and off state
+Patch17:	8477afa53995841d84d209eaa3516c98e3830052.patch
+# Bound R2004 DWG page decoding
+Patch18:	17ba2b273b89cc9c8b6fcf71882e327ccf1eebf6.patch
+# NOT UPSTREAM: Properly init buffer var
+Patch19:	libdxfrw-dwgbuffer-uninit.patch
 
 
-# All of these patches are committed but not in the LibreCAD 2.2 branch, 3.0 work?
-
-# Merging qt6
-# https://github.com/LibreCAD/LibreCAD/commit/ab3e44e28b282e3c4d304db37264d0c6e2142ad8
-Patch11:	ab3e44e28b282e3c4d304db37264d0c6e2142ad8.patch
-# Compiler warnings
-# https://github.com/LibreCAD/LibreCAD/commit/7cf1408247e1c03aba86ddebd951d1e413c26fa3
-Patch12:	7cf1408247e1c03aba86ddebd951d1e413c26fa3.patch
-# Improved preview on actions, copy/paste, shortcuts etc.
-# https://github.com/LibreCAD/LibreCAD/commit/05c0f3bd865aae21f453965a504d215a63a02782
-Patch13:	05c0f3bd865aae21f453965a504d215a63a02782.patch
-# Rendering performance (#1922)
-# https://github.com/LibreCAD/LibreCAD/commit/8b3cf9caf984dff07df2c83f685c9bd7a175df67
-Patch14:	8b3cf9caf984dff07df2c83f685c9bd7a175df67.patch
-# Views and actions (#1958)
-# https://github.com/LibreCAD/LibreCAD/commit/a46f1967474e7a39cf82e45464000373503fabbe
-Patch15:	a46f1967474e7a39cf82e45464000373503fabbe.patch
-# Arcs and splines (#1967)
-# https://github.com/LibreCAD/LibreCAD/commit/7838da61f71baf93c722c05f7c4c80f802cd06a1
-Patch16:	7838da61f71baf93c722c05f7c4c80f802cd06a1.patch
-# fixed a compiler warning
-# https://github.com/LibreCAD/LibreCAD/commit/3c55e604ea9622bfaac33bbd83ebab3b26293e27
-Patch17:	3c55e604ea9622bfaac33bbd83ebab3b26293e27.patch
-# User Coordinates, Angles Basis, Angles format for input, etc.
-# https://github.com/LibreCAD/LibreCAD/commit/c42f4f644f22a90a7e5d8cc0892f4e630737abc6
-Patch18:	c42f4f644f22a90a7e5d8cc0892f4e630737abc6.patch
-# Ordinate Dimensions (#2131)
-# https://github.com/LibreCAD/LibreCAD/commit/944e6340fe5a1e17a4e44d9de25c78131bfb4cb5
-Patch19:	944e6340fe5a1e17a4e44d9de25c78131bfb4cb5.patch
-# MText: fixed a division by zero (for libdxfrw this is just a newline cleanup)
-# https://github.com/LibreCAD/LibreCAD/commit/5abf92a84416d82978a1bff94736ec7cdc709ad4
-Patch20:	5abf92a84416d82978a1bff94736ec7cdc709ad4.patch
-# static-analysis warnings
-# https://github.com/LibreCAD/LibreCAD/commit/3f16299c1c7a6fec9ff8fc85ce989cbe3bcb9659
-Patch21:	3f16299c1c7a6fec9ff8fc85ce989cbe3bcb9659.patch
-
 %description
 libdxfrw is a free C++ library to read and write DXF files in both formats,
 ASCII and binary form.
@@ -112,20 +94,15 @@ Development files for libdxfrw.
 %patch -P8 -p1 -b .d7b5b0a30bc096ec7a6802a2806258f9e6e39fea
 %patch -P9 -p1 -b .4dc3d5fa4b328873af07be05d7b67e5846628eb7
 %patch -P10 -p1 -b .1603a1ac5ef804b50b8fb583662c0bdcbf9ec72c
-# LibreCAD 3?
-%if 0
-%patch -P11 -p1 -b .ab3e44e28b282e3c4d304db37264d0c6e2142ad8
-%patch -P12 -p1 -b .7cf1408247e1c03aba86ddebd951d1e413c26fa3
-%patch -P13 -p1 -b .05c0f3bd865aae21f453965a504d215a63a02782
-%patch -P14 -p1 -b .8b3cf9caf984dff07df2c83f685c9bd7a175df67
-%patch -P15 -p1 -b .a46f1967474e7a39cf82e45464000373503fabbe
-%patch -P16 -p1 -b .7838da61f71baf93c722c05f7c4c80f802cd06a1
-%patch -P17 -p1 -b .3c55e604ea9622bfaac33bbd83ebab3b26293e27
-%patch -P18 -p1 -b .c42f4f644f22a90a7e5d8cc0892f4e630737abc6
-%patch -P19 -p1 -b .944e6340fe5a1e17a4e44d9de25c78131bfb4cb5
-%patch -P20 -p1 -b .5abf92a84416d82978a1bff94736ec7cdc709ad4
-%patch -P21 -p1 -b .3f16299c1c7a6fec9ff8fc85ce989cbe3bcb9659
-%endif
+%patch -P11 -p1 -b .1a8202f1dc39c52d20ca49e697de9cc2c2d4fb0c
+%patch -P12 -p1 -b .03fa108ab2fd74ab7b070daf5b36b29eb0428536
+%patch -P13 -p1 -b .1eeda16c23f738fd934d467e90582f86e4d77794
+%patch -P14 -p1 -b .fb40d56d42d96866af25aed56b1f60a627e43a49
+%patch -P15 -p1 -b .d11a8d909ede733aa5fa3b20da17bbb5aeb2f21e
+%patch -P16 -p1 -b .a536057a928aa051b6339d51f6764ff5c386c92f
+%patch -P17 -p1 -b .8477afa53995841d84d209eaa3516c98e3830052
+%patch -P18 -p1 -b .17ba2b273b89cc9c8b6fcf71882e327ccf1eebf6
+%patch -P19 -p1 -b .dwgbuffer-uninit
 
 %build
 export CXXFLAGS="%{optflags} -Wno-error=unused-parameter -Wno-error=return-type"
@@ -167,6 +144,9 @@ export CXXFLAGS="%{optflags} -Wno-error=unused-parameter -Wno-error=return-type"
 %{_libdir}/pkgconfig/libdxfrw.pc
 
 %changelog
+* Tue Nov 24 2026 Tom Callaway <spot@fedoraproject.org> - 1.1.0-0.14.rc1
+- apply more fixes from the 2.2.1 LibreCAD git tree
+
 * Thu Jul 16 2026 Fedora Release Engineering <releng@fedoraproject.org> - 1.1.0-0.13.rc1
 - Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild
 

                 reply	other threads:[~2026-11-24 22:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179555987596.1.5672020969992060417.rpms-libdxfrw-f58e6ebce060@fedoraproject.org \
    --to=spotaws@amazon.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox