Menu

memset() may destroy heap in getname()

2014-08-08
2014-08-08
  • Christian Franke

    This likely may destroy the heap:

    ddru_ntfsbitmap.c(314) allocates 512 bytes:

      inchar = calloc(512, sizeof(char));
      ...
      inchar_start = inchar;
    

    ddru_ntfscommon.c(55) fills 1024 bytes:

      memset (inchar_start, 0, 1024);
    

    I would suggest to use fixed size arrays and sizeof() here as iconv() does not require malloc()ed buffers.

     
  • maximus57

    maximus57 - 2014-08-08

    OOPS! It should have allocated 1024 bytes to begin with, I will have to fix that.

    As for iconv() not requiring malloc()ed buffers, I don't remember exactly why I did everything the way I did, but I do know that iconv() has a bastard of a memory leak, and I spent some quality time figuring out how to write my code around it to minimize that leak to avoid program crashes. So I will not likely change coding of iconv() unless it is to fix something that is actually broken.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.