In 5.2  win32, my snmp commands now crash, quite early on.

 

I tracked it to netsnmp_getenv() in libsnmp\tools.c.  First, it sets temp = getenv(name), then looks in the registry if name was not found in the registry.  Then it calls setenv(temp) to set it from now on.  Then (here comes the crash), it calls SNMP_FREE(temp).  If temp was found in the environment first (not the registry), this crashes.  On the second call for the same variable, it will certainly be found in the environment, and we crash.

 

Also, I found that when I just download and build the source, and use build.bat, and let it install after building, the registry is not set with the net-SNMP variables.  Running win32\install-net-snmp.bat does not help.  I had to install the binaries, to get the variables in the environment.

 

I did a quick fix to tools.c to prevent the freeing of vars returned from getenv():

 

  int got_env = 0;             // PWG kludge to avoid freeing temp from getenv()

/* Try environment variable first */

  temp = getenv(name);

  if (temp){

    DEBUGMSGTL(("read_config", "netsnmp_getenv will return from ENV: %s\n",temp));

          got_env =1;            // PWG added

  }

  if (temp && !got_env) {             // PWG added !got_env

    setenv(name, temp, 1);

    SNMP_FREE(temp);

  }

 

That seems to get me going.  Am I missing some config issue that makes this problem happen just for me?  Anyone else trying 5.2 on win32?

 

Thanks,

 

Phil Gillis

 

Reply via email to