how to fix stack smashing protect failure in ESP32

By null-terminated string I mean to use something like:

#define MAX_STR_LEN     256
char szNullString[MAX_STR_LEN];

and small-s string functions like sprintf(szNullString, "...) strcat(szNullString, ...) etc to manipulate them.

Capital-S String(...) stuff requires a lot of memory and machine cycles. They are generally frowned upon by the Arduinoista because they're known to cause memory problems and crashes in lesser processors. I don't know if the ESP32 & its compilation/linking tools are susceptible to the same issues but since you're using Strings and are having what appear to be stack issues it makes sense to me to try the alternative.