memcpy with negative length and destination on heap - exploitable?

From: 3APA3A (3APA3A@SECURITY.NNOV.RU)
Date: 12/24/01


Date: Mon, 24 Dec 2001 12:59:30 +0300
From: 3APA3A <3APA3A@SECURITY.NNOV.RU>
To: vuln-dev@security-focus.com

Hello vuln-dev,

  Theoretically, are there are any situations, then it's possible to
  exploit this kind of bug:

   ...
   char src[FEW * KB_OF_DATA], * dst;
   int len;
   ...

   get_user_input(src, sizeof(src));
   len = src[POSITION]; /* char is signed and can be negative! */
   dst = malloc(256);
   memcpy(dst, src + POSITION + 1, len);

   ...

   len is too long then converted to size_t and memcpy will crash... Is
   it possible to avoid it if destination buffer is on heap? Program is
   available on all possible platforms :)

-- 
http://www.security.nnov.ru
         /\_/\
        { , . }     |\
+--oQQo->{ ^ }<-----+ \
|  ZARAZA  U  3APA3A   }
+-------------o66o--+ /
                    |/
You know my name - look up my number (The Beatles)



Relevant Pages

  • Re: Writing a unittest against thread (un)safe ref-counter pointer
    ... frustrations before the bug was discovered. ... If your memory is clean afterwards and the program did not crash it is likely that your reference counter is clean. ... I have not found anything better than experience and much care for now to avoid synchronization issues in core libraries of mutli-threaded applications. ...
    (comp.programming.threads)
  • Re: Adding hyphens and underscore to my JS expression test
    ... > in Mozilla which includes other characters from the Unicode repertoire. ... It appears that this bug was fixed in Mozilla/5.0 release version 1.8 ... > so I decided to avoid the hassle in my previous post. ... crossposting so without Followup-To is even worse. ...
    (comp.lang.javascript)
  • Re: 2.6.25-rc6-git6: Reported regressions from 2.6.24
    ... The way to avoid ... that bug is to install the dbus-x11 package which forces dbus to start ...
    (Linux-Kernel)
  • Re: D7.1 Update ready for primetime?
    ... > bug fixes into previous versions. ... > tries to avoid something that will knowingly crash the application. ... you have to support more exotic languages and switch locales it's not so ... > in a different source control system that they no longer used and the ...
    (borland.public.delphi.non-technical)
  • Re: Nasty crash
    ... "Stas" wrote in message... ... I am wondering if this is a known bug, and if so, is there a way to avoid ... I find that crashes in ADOM are exceptionally rare (I know others ...
    (rec.games.roguelike.adom)