Git Product home page Git Product logo

libredwg's Introduction

LibreDWG

LibreDWG is a free C library to read and write DWG files.  This program is
part of the GNU project, released under the aegis of GNU.  It is licensed
under the terms of the GNU General Public License version 3 (or at you option
any later version).

DWG is a file format created in the 70's for the emerging CAD applications.
Currently it is the native file format of AutoCAD, a proprietary CAD program 
developed by AutoDesk.

LibreDWG is a fork from LibDWG due to its usage of Esperanto, which we think
is not the best strategy for a free software project which aims to get lots of
contributors.  LibreDWG is written in English.  Since we forked LibDWG (May
16, 2009), its development seems to have been inactive.  At the moment
(September 25, 2009) our decoder is almost done.  We are reaching 100% read
support in our data structures parser but we still need a test suite.  Among
the example applications we wrote using LibreDWG is an initial SVG conversion
tool. Please contact us if you can help.

The program dwg_ps (in examples/) reads DWG and outputs Postscript; it
depends on pslib: <http://pslib.sourceforge.net>.  In many GNU/Linux
distributions, this is available by installing the pslib-dev package.
If the configure script does not find pslib, dwg_ps will not be built.

Sometimes we hang on our IRC channel which is #libredwg at irc.freenode.net
If you don't find us there, please email the package maintainers:

Felipe Corrêa da Silva Sanches <[email protected]>
Rodrigo Rodrigues da Silva <[email protected]>

If you are looking for general information about the project, check our website:
http://www.gnu.org/software/libredwg

== Building and installing the library ==

You need the following dependencies:
- Basic development tools (gcc, autoconf and libtool)
- SWIG 1.7+
- TeXinfo
- Python development headers (debian: python-dev; yum: python-devel)

See INSTALL for generic instructions.  Basically, you do:

$ ./autogen.sh (if you checked out the source code from git)
$ ./configure [options]
$ make
$ make check    # optional but strongly encouraged while LibreDWG is alpha
$ make install

This builds and installs various files in the "installation dirs":
  $libdir     ($exec_prefix/lib)   -- library files (libredwg.*)
  $includedir ($prefix/include)    -- dwg.h
  $infodir    ($datarootdir/info)  -- LibreDWG.info

Use "./configure --help" to see a full list of options you can use to
customize the installation dirs.  Other options recognized by configure are:

  --enable-trace

    NB: This is an experimental feature that is not in its final form.

    Enable runtime tracing (default: no).  When enabled, the environment
    variable LIBREDWG_TRACE is consulted on the first decode/encode attempt.
    Its value is an integer: 0 (no output) through 9 (full verbosity).

  --enable-write
  
    NB: This is an experimental feature that is not in its under construction, so its highly unstable.
    
    Enable write support (default: no). When enabled you activate the write
    support for the dwg format.

== Example usage of the library ==

The examples directory contains some application code that uses our lib:

* load_dwg.c -- This is a skeleton code.  Look there if you want to have a
  quickly glance on how to use the library.

* dwg_ps.c -- Opens a DWG file and outputs an PostScript file.  This code
  depends on the PSlib library.  On Debian-based systems this is usually
  available as a package named pslib-dev

* testSVG.c -- Opens a DWG file and outputs an SVG (Scalable Vector Graphics)
  file.  SVG is a W3C standard for 2d vector graphics.  You can open these
  files on several free software tools.  We recomend Inkscape, a free software
  vector graphics editor.  The testSVG.c program will not handle 3d content
  from DWG since SVG only supports 2-dimensional images.

* get_bmp.c -- Extracts the bmp thumbnail of a dwg file when it is available.

* rewrite.c -- Load, rewrite and try to re-read a existing dwg file. Just for writing test. Still failing (as in 08/2010) 

/*****************************************************************************/
/*  LibreDWG - free implementation of the DWG file format                    */
/*                                                                           */
/*  Copyright (C) 2009, 2010 Free Software Foundation, Inc.                  */
/*                                                                           */
/*  This library is free software, licensed under the terms of the GNU       */
/*  General Public License as published by the Free Software Foundation,     */
/*  either version 3 of the License, or (at your option) any later version.  */
/*  You should have received a copy of the GNU General Public License        */
/*  along with this program.  If not, see <http://www.gnu.org/licenses/>.    */
/*****************************************************************************/

libredwg's People

Contributors

andersoncardoso avatar bolche avatar duvisit avatar felipesanches avatar rbvermaa avatar rodrigopitanga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libredwg's Issues

invail pointer deference in libredwg

libredwg(crash)

github address

https://github.com/ArchimedesCAD/libredwg

compile the test case in the source

./configure
make
gcc testSVG.c -I../src/ ../src/.libs/libredwg.a -lm  -o fuzz_svg

test with poc

./fuzz_svg segment_poc 

the gdb output

Program received signal SIGSEGV, Segmentation fault.

[----------------------------------registers-----------------------------------]
RAX: 0x1f5 
RBX: 0x0 
RCX: 0x1b 
RDX: 0x2 
RSI: 0x629390 --> 0x4003 
RDI: 0x6d1480 --> 0x3000000017 
RBP: 0x7fffffffd690 --> 0x7fffffffd6f0 --> 0x7fffffffe240 --> 0x7fffffffe260 --> 0x0 
RSP: 0x7fffffffd668 --> 0x40171d (<output_BLOCK_HEADER+227>:	mov    QWORD PTR [rbp-0x10],rax)
RIP: 0x401e0f (<get_first_owned_object+63>:	mov    rax,QWORD PTR [rax])
R8 : 0x7fffffff 
R9 : 0x414fc0 ("Found null object reference. Could not output an SVG symbol for this BLOCK_HEADER\n")
R10: 0x7ffff7acc6a0 --> 0x0 
R11: 0x246 
R12: 0x400d90 (<_start>:	xor    ebp,ebp)
R13: 0x7fffffffe340 --> 0x2 
R14: 0x0 
R15: 0x0
EFLAGS: 0x10246 (carry PARITY adjust ZERO sign trap INTERRUPT direction overflow)
[-------------------------------------code-------------------------------------]
   0x401e00 <get_first_owned_object+48>:	repz ret 
   0x401e02 <get_first_owned_object+50>:	nop    WORD PTR [rax+rax*1+0x0]
   0x401e08 <get_first_owned_object+56>:	mov    rax,QWORD PTR [rsi+0x98]
=> 0x401e0f <get_first_owned_object+63>:	mov    rax,QWORD PTR [rax]
   0x401e12 <get_first_owned_object+66>:	ret    
   0x401e13:	data32 data32 data32 nop WORD PTR cs:[rax+rax*1+0x0]
   0x401e20 <get_next_owned_object>:	mov    rax,QWORD PTR [rdi+0x30]
   0x401e24 <get_next_owned_object+4>:	mov    eax,DWORD PTR [rax]
[------------------------------------stack-------------------------------------]
0000| 0x7fffffffd668 --> 0x40171d (<output_BLOCK_HEADER+227>:	mov    QWORD PTR [rbp-0x10],rax)
0008| 0x7fffffffd670 --> 0x41519c --> 0x3e736665643c09 ('\t<defs>')
0016| 0x7fffffffd678 --> 0x6295f0 --> 0x6d1480 --> 0x3000000017 
0024| 0x7fffffffd680 --> 0x0 
0032| 0x7fffffffd688 --> 0x629390 --> 0x4003 
0040| 0x7fffffffd690 --> 0x7fffffffd6f0 --> 0x7fffffffe240 --> 0x7fffffffe260 --> 0x0 
0048| 0x7fffffffd698 --> 0x401935 (<output_SVG+469>:	add    DWORD PTR [rbp-0x34],0x1)
0056| 0x7fffffffd6a0 --> 0x40d1a0a52e680c34 
[------------------------------------------------------------------------------]
Legend: code, data, rodata, value
Stopped reason: SIGSEGV
0x0000000000401e0f in get_first_owned_object (hdr_obj=0x6d1480, hdr=0x629390) at dwg.c:359
359	      return hdr->first_entity->obj;
gdb-peda$ p hdr->first_entity 
$1 = (Dwg_Object_Ref *) 0x1f5   # !!!!!!   illegal pointer
gdb-peda$ p hdr->first_entity->obj
Cannot access memory at address 0x1f5
gdb-peda$ 

As you can see, the hdr->first_entity is now a illegal pointer , and we got crash

Program received signal SIGSEGV, Segmentation fault.

By using asan , I found this is an heap overflow vulnerability

the binary and the poc:

http://hac425.unaux.com/usr/uploads/2018/07/2407654350.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.