Skip to main content.
home | support | download

Back to List Archive

Bug : filename suffix may cause memory fault

From: Yann Stettler <stettler(at)>
Date: Thu Dec 10 1998 - 18:58:48 GMT
When swich-e test if a file should be indexed or
not based on it's suffix (NoContents rule among others),
it will cause a memory fault if the suffix is more than
10 characters in lenght (MAXSUFFIXLEN constant).
Ie: afile.withalongsuffix  will crash the program.

In the function : isoksuffix(), the characters following
the last "." in the filename are copied to a buffer
of MAXSUFFIXLEN which may quite easly be too small...

I suggest the following changes to issuffix() :

int isoksuffix(filename, rulelist)
char *filename;
struct swline *rulelist;
        int badfile, len;
        char *c, suffix[MAXSUFFIXLEN], checksuffix[MAXSUFFIXLEN];
        struct swline *tmplist;

        tmplist = rulelist;
        if (tmplist == NULL)
                return 1;
        if ((c = (char *) strrchr(filename, '.')) == NULL)
                return 0;

        if (strlen(c+1) >= MAXSUFFIXLEN)
             return 0;

        badfile = 1;

Note that in the above I choose to consider that file
with a too long suffix _should_ be indexed. That's because
I am using this function with the HTML method and have
database query in URLs.

Yann Stettler

TheNet - Internet Services AG              CohProg SaRL                           
Anime and Manga Services         
Received on Thu Dec 10 10:57:06 1998