- use dynamic allocation instead to avoid overflows
- also update addFile(), which is actually the only function
that calls parseForRegexLang()
static int initialized = 0;
static int hasRegex = 0;
static regex_t compiledPatt;
- static char buf[BUFSIZ];
+ char *buf;
int x;
regmatch_t matches[2];
const char *s;
/* Got match */
s = fileName + matches[1].rm_eo - 1;
x = matches[1].rm_eo - matches[1].rm_so;
+ buf = xmalloc(x+1);
buf[x] = '\0';
- while (x) {
- buf[--x] = *s--;
- }
+ memcpy(buf, s, x);
if (lang)
*lang = buf;
+ else {
+ free(buf);
+ return 1;
+ }
return 0;
}
gid_t fileGid;
const char *fileUname;
const char *fileGname;
- char *lang;
/* Path may have prepended buildRootURL, so locate the original filename. */
/*
*ncl++ = *ocl;
*ncl = '\0';
}
- } else if (! parseForRegexLang(fileURL, &lang)) {
- flp->langs = xstrdup(lang);
- } else {
+ } else if (parseForRegexLang(fileURL, &flp->langs)) {
flp->langs = xstrdup("");
}