[syslinux] tftp-hpa: getopt problems

Gernot Hillier gernot.hillier at siemens.com
Thu Aug 19 07:24:31 PDT 2004


I hope this is the right list for sending tftpd-patches - if not, please point 
me in the right direction...

I experienced quite strange problems when trying to use tftp-hpa in newer 
Cygwin versions. It simply isn't able to parse its command line correctly 
because it seems to use another optind variable than getopt().

When you try to start it with something like

tftpd.exe -s /mypath

it complains about "too much -s directories". After some debugging, I found, 
that this code in main() 

--- SNIP ---
  dirs = xmalloc((argc-optind+1)*sizeof(char *));
  for ( ndirs = 0 ; optind != argc ; optind++ )
    dirs[ndirs++] = argv[optind];
--- SNAP ---

sees the wrong value for optind. The attached trivial patch resolves this 
problem for me and is also the suggested way to use getopt according to the 
man page. 

Therefore it should definitely not harm (also not for Linux) to include it in 

TIA for applying this patch!


Gernot Hillier
Siemens AG, Mch P

More information about the Syslinux mailing list