Project: liblouis (liblouis/liblouis), language: c++
Vulnerability instance: liblouis.cve-2018-11577
Sanitizer: address

================= Bug Report (1/1) ==================
## Source: GitHub Issue
## URL: https://github.com/liblouis/liblouis/issues/582
## Description:
Issue: liblouis/liblouis#582
Title: SEGV-logging-c-148
State: closed
Created by: Edward-L
Created at: 2018-05-30 09:52:20+00:00
Labels: bug, memory error

Issue Body:
asan report 
```
ASAN:SIGSEGV
=================================================================
==59249==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x7f862930f3dc sp 0x7ffc3e653ca0 bp 0x000000000001 T0)
    #0 0x7f862930f3db in __vfprintf_chk (/lib/x86_64-linux-gnu/libc.so.6+0x10d3db)
    #1 0x40d5d7 in vfprintf /usr/include/x86_64-linux-gnu/bits/stdio2.h:127
    #2 0x40d5d7 in lou_logPrint /opt/lxf/liblouis-master/liblouis/logging.c:148
    #3 0x40d32f in _lou_logMessage /opt/lxf/liblouis-master/liblouis/logging.c:114
    #4 0x401afd in compileError /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:272
    #5 0x402420 in parseDots /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:1271
    #6 0x4024a7 in passGetDots /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:1584
    #7 0x405ce9 in compilePassOpcode /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:2561
    #8 0x40896a in compileRule /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:3974
    #9 0x40af72 in compileFile /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:4498
    #10 0x40b265 in compileTranslationTable /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:4603
    #11 0x40b265 in lou_getTable /opt/lxf/liblouis-master/liblouis/compileTranslationTable.c:4688
    #12 0x40162a in main /opt/lxf/liblouis-master/tools/lou_checktable.c:112
    #13 0x7f8629223f44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
    #14 0x401854 (/opt/lxf/liblouis-master/tools/.libs/lou_checktable_static_asan+0x401854)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ??:0 __vfprintf_chk
==59249==ABORTING
```
poc:[poc](https://github.com/Edward-L/fuzzing-pocs/blob/master/liblouis/SEGV-logging-c-148.poc)


Comments:
Comment by abergmann on 2018-06-05 06:29:32+00:00:
[CVE-2018-11577](https://nvd.nist.gov/vuln/detail/CVE-2018-11577) was assigned to this issue.

Build script:
#!/bin/bash
# Default build script template for C/C++ projects
set -eu

# Define configuration options
CONFIG_OPTS="--disable-shared"
CMAKE_OPTS="-DCMAKE_BUILD_TYPE=Debug"
MAKE_OPTS="-j$(nproc)"
BUILD_DIR="build"

# 1. Run build preparation scripts if they exist
for prep_script in buildconf autogen.sh bootstrap; do
  if [ -x "$prep_script" ]; then
    echo "Running $prep_script..."
    ./$prep_script
    break
  elif [ -f "$prep_script" ]; then
    echo "Found $prep_script but it's not executable, setting permissions..."
    chmod +x $prep_script
    ./$prep_script
    break
  fi
done

# 2. Handle different build systems
if [ -f "configure" ]; then
  echo "Found configure script, running with options: $CONFIG_OPTS"
  ./configure $CONFIG_OPTS

  echo "Building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -f "CMakeLists.txt" ]; then
  echo "Found CMakeLists.txt, using CMake build system"
  mkdir -p $BUILD_DIR
  cd $BUILD_DIR
  cmake $CMAKE_OPTS ..
  make $MAKE_OPTS
elif [ -f "Makefile" ] || [ -f "makefile" ]; then
  echo "Found Makefile, building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -f "meson.build" ]; then
  echo "Found meson.build, using Meson build system"
  mkdir -p $BUILD_DIR
  meson setup $BUILD_DIR .
  cd $BUILD_DIR
  ninja
elif [ -f "GNUmakefile" ]; then
  echo "Found GNUmakefile, building with make $MAKE_OPTS"
  make $MAKE_OPTS
elif [ -d ".git" ] && [ -f "Makefile.am" ]; then
  echo "Found Makefile.am, running autoreconf"
  autoreconf -i
  ./configure $CONFIG_OPTS
  make $MAKE_OPTS
else
  echo "WARNING: No recognized build system found!"
  echo "Trying generic approach:"
  
  # Try to detect common source patterns and compile them
  if ls *.c >/dev/null 2>&1 || ls *.cpp >/dev/null 2>&1 || ls *.cc >/dev/null 2>&1; then
    echo "Found C/C++ source files, attempting direct compilation"
    if ls *.cpp >/dev/null 2>&1 || ls *.cc >/dev/null 2>&1; then
      CXX=${CXX:-g++}
      echo "Compiling C++ sources with $CXX"
      $CXX -g -O1 -fsanitize=address -fno-omit-frame-pointer -o main *.cpp *.cc 2>/dev/null || true
    elif ls *.c >/dev/null 2>&1; then
      CC=${CC:-gcc}
      echo "Compiling C sources with $CC"
      $CC -g -O1 -fsanitize=address -fno-omit-frame-pointer -o main *.c 2>/dev/null || true
    fi
  fi
fi

Dockerfile:
FROM hwiwonlee/secb.base:latest
RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-config zlib1g-dev libpci-dev
RUN git clone https://github.com/liblouis/liblouis liblouis
RUN git -C liblouis checkout 0dee1fcc102678e8a57f59ba53f0a9784b93b4ae
WORKDIR $SRC/liblouis
COPY build.sh $SRC/

Additional files: