Mg_stat() triggers segmentation fault on 32-bit machine

I’ve been using the mongoose web server for a while and it has been working well on a 64-bit system. Just recently I needed to recompile a program using mongoose for use on a 32-bit machine.

The program calls mg_stat() to check if the web root directory exists. That call works on a 64-bit machine but on the 32-bit machine it results in a “stack smashing” segmentation fault and kills the program.

I suspect some variable is getting declared using a type defined in a system supplied header file and it winds up as a 32-bit entity but mg_stat() is calling something that expects the variable to be 64-bit. This has me wondering if there are some other functions in the mongoose server that may not be 32-bit safe.

Make sure that the argument for mg_stat is correct.

  mg_stat_t st;
  int result = mg_stat(path, &st);