Giter VIP home page Giter VIP logo

dwgo's People

Contributors

gasparfm avatar

Stargazers

 avatar

Watchers

 avatar  avatar

dwgo's Issues

Security Issue : Two Buffer Overflows -- insufficient malloc size

The manual page for strcat (3) explains

  The strcat() function appends the src string to the dest string, overwriting the
  terminating null byte ('\0') at the end of dest, and then adds a terminating null byte.

  The strings may not overlap, and the dest string must have enough space for the result.

  If dest is not large enough, program behavior is unpredictable; buffer overruns are 
  a favorite avenue for attacking secure programs.

The destination for strcat on lines 324 and 325 of dwgo.cpp are only suffcient for the strings being copied but not the additional terminating null byte.

dwgo.cpp:324:  other_dir=(char*)malloc(strlen(homedir)+6);  strcpy(other_dir, homedir);  
               strcat(other_dir, (char*)"/.dwgo");

dwgo.cpp:325:  datadir  =(char*)malloc(strlen(DATADIR)+5);  strcpy(datadir, DATADIR); 
               strcat(datadir, (char*)"/dwgo");

To accommodate the additional terminating null byte, each call to malloc needs an increase in size by one.

Line 324 should contain "+7" not "+6", viz the length of the string "/.dwgo" plus one for the terminator.

Line 325 should contain "+6" not "+5", viz the length of the string "/dwgo" plus one for the terminator.

Some may think that because the orginal strings for homedir and DATADIR, which are used in calculating the size of the destinations, contain a terminating null byte, that the length of the destination strings should be adequate without the "+1", but this overlooks the fact that (from the manual page of strlen (3)

    The strlen() function calculates the length of the string s,
    excluding the terminating null byte ('\0').

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.