[liblouis-liblouisxml] [liblouis/liblouis] 922cd2: Fix for stackoverflow crashes on applications with...

  • From: Christian Egli <christian.egli@xxxxxx>
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Tue, 08 Nov 2016 01:08:43 -0800

  Branch: refs/heads/master
  Home:   https://github.com/liblouis/liblouis
  Commit: 922cd2e52a63a8c50c82081ba61dcdbe560a810f
      
https://github.com/liblouis/liblouis/commit/922cd2e52a63a8c50c82081ba61dcdbe560a810f
  Author: vsmontalvao <vsmontalvao@xxxxxxxxx>
  Date:   2016-11-03 (Thu, 03 Nov 2016)

  Changed paths:
    M liblouis/compileTranslationTable.c

  Log Message:
  -----------
  Fix for stackoverflow crashes on applications with smaller stack size

This change moves the memory allocation for the patterns variable from
the stack to the heap inside the compileRule function. The patterns
variable was a widechar array with size 27720 which usually takes 54KB
of memory (or 108KB if UCS=4). When there's not available memory on the
stack this could lead to stackoverflow crashes or accessing unmapped
memory. As this variable is declared in 2 places (with different scopes)
inside the function, an executable could require at least 108KB (or
216KB if USC=4) of stack memory per compileRule call.
Similarly to other places, it also adds a check which calls outOfMemory
in case of not having sufficient available memory on the heap.
The fix is especially important if we consider that some applications
might have smaller stack size limits and requiring large ammounts of
stack size (e.g. >100KB) for a single function call can cause such
crashes.


  Commit: 67a439a5599bd57835a6615eca70013213f05667
      
https://github.com/liblouis/liblouis/commit/67a439a5599bd57835a6615eca70013213f05667
  Author: Christian Egli <christian.egli@xxxxxx>
  Date:   2016-11-08 (Tue, 08 Nov 2016)

  Changed paths:
    M liblouis/compileTranslationTable.c

  Log Message:
  -----------
  Merge pull request #220 from vsmontalvao/vsmontalvao-stackoverflowfix

Fix for stackoverflow crashes on applications with smaller stack size


Compare: 
https://github.com/liblouis/liblouis/compare/98bd6097b860...67a439a5599b

Other related posts:

  • » [liblouis-liblouisxml] [liblouis/liblouis] 922cd2: Fix for stackoverflow crashes on applications with... - Christian Egli