Proxmark3 community

Research, development and trades concerning the powerful Proxmark3 device.

Remember; sharing is caring. Bring something back to the community.


"Learn the tools of the trade the hard way." +Fravia

  • Logged in as ikarus
  • Last visit: Today 11:22:42

Announcement

Time changes and with it the technology
Proxmark3 @ discord

Users of this forum, please be aware that information stored on this site is not private.

#1 2010-04-02 23:19:09

toffe
Member
Registered: 2010-03-07
Posts: 13

OSX client crashes on command mandemod

It seems the current SVN version of mandemod allocates too much stackspace which causes an EXC_BAD_ACCESS signal to the proxmark3 client process. It happens as soon as you enter the CmdManchesterDemod function. I've found the cause of the issue, which could be of interest to anyone developing the proxmark3 client:

The default stack size of pthread on OSX is 512kB.

This, in combination with the stack allocation of

int BitStream[MAX_GRAPH_TRACE_LEN];

will cause a stack overrun. MAX_GRAPH_TRACE_LEN is currently 128*1024, multiplied by the number of bytes in an int (4) equals 512kB --> BAM!

There are a couple of ways of dealing with this. Since at most two bits of each element of the array is used, it would work to change the type to uint8_t. It may still be justifiable to malloc() the array. Also, one could set the stack size of the main thread to something larger -- but why waste memory if you don't need to?

I'm willing to fix this issue, I just need someone to either give me Commit permission to the repository or apply the patch. Thanks!

===================================================================
--- cmddata.c  (revision 434)
+++ cmddata.c  (working copy)
@@ -561,7 +561,7 @@
 
   /* But it does not work if compiling on WIndows: therefore we just allocate a */
   /* large array */
-  int BitStream[MAX_GRAPH_TRACE_LEN];
+  uint8_t BitStream[MAX_GRAPH_TRACE_LEN];
 
   /* Detect high and lows */
   for (i = 0; i < GraphTraceLen; i++)

Offline

Quick reply

Write your message and submit

Board footer

Powered by FluxBB