[Box Backup-dev] Problems with command line parsing in getopt(..)

Mark boxbackup-dev@fluffy.co.uk
Fri, 24 Feb 2006 15:03:31 +0100


I think I've found a possible problem in the function getopt(..) in emu.h:

do
    {
        if (index != -1)
        {
            str = str.substr(index+1, str.size());
        }

        index = (int)str.find('-');

        if (index == -1) return -1;

        opt = str[1];

        optind ++;
        str = args[optind];
    }
    while ((opttolookfor = (int)interestin.find(opt)) == -1);  

Shouldn't there be a check in this while loop to ensure (optind < 
count), just like the check done at the start of the function?