fix buffer overflow vulnerability in NetGenFunc