diff --git a/io/hpmud/model.c b/io/hpmud/model.c index d546ec1..288cd75 100644 --- a/io/hpmud/model.c +++ b/io/hpmud/model.c @@ -407,7 +407,10 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int * char rcbuf[255]; char section[128]; char file[128]; - int found=0, n; + int found=0; + size_t n; + + size_t model_len = strlen(model); if ((fp = fopen(datFile, "r")) == NULL) goto bugout; @@ -423,9 +426,15 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int * n = strlen(section); section[n-2]=0; /* remove ']' and CR */ if (strcasecmp(model, section) == 0 || - (section[0] == 'h' && section[1] == 'p' && - section[2] == '_' && - strcasecmp(model, section + 3) == 0)) + (section[0] == 'h' && + section[1] == 'p' && + section[2] == '_' && + strcasecmp(model, section + 3) == 0) || + (n > model_len && + strncasecmp(section, model, model_len) && + strncasecmp(section + model_len, "_series", strlen("_series")) + ) + ) { /* Found model match. */ *bytes_read = ResolveAttributes(fp, attr, attrSize);