Just to make things clearer (I hope....), I modified the snippet above
as follows:

          strncpy(hlp,optarg,299); 
          printf("hlp  :%x-\n", hlp);
          printf("hlp  :%s-\n", hlp);
          hlp2=strtok(hlp,":");
          printf("hlp  :%x-\n", hlp);
          printf("hlp  :%s-\n", hlp);
          printf("hlp2 :%x-\n", hlp2);
          IP[255]=0;
          strncpy(IP,hlp,255);          

Now, if I run the program as sudo sniffit -t192.1.100.1 I get the
following:

hlp  :fd6089d0-
hlp  :192.1.100.1-
hlp  :fd6089d0-
hlp  :192.1.100.1-
hlp2 :fd6089d0-
Supported Network device found. (eth0)
Sniffit.0.3.7 Beta is up and running.... (192.1.100.1)

Note that hlp and hlp2 both point to the same NULL terminated string.
The only difference is that hlp is size bound. If I insert a printf of
hlp2 of I try to use it I get a SIGSEGV.

If I run the program as sudo sniffit -t192.1.100.1:80 I get the
following:

hlp  :579cfd90-
hlp  :192.1.100.1:80-
hlp  :579cfd90-
hlp  :192.1.100.1-
hlp2 :579cfd90-
Supported Network device found. (eth0)
Sniffit.0.3.7 Beta is up and running.... (192.1.100.1)

Again, hlp and hlp2 are pointing to the same NULL terminated string but
any attempt to use hlp2 lead to SIGSEGV. hlp can be used with no
problem!?

-- 
Segmentation Fault
https://bugs.launchpad.net/bugs/107180
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to