diff --git a/io/hpmud/model.c b/io/hpmud/model.c index d546ec1..5bb6091 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; @@ -422,10 +425,16 @@ static int ParseFile(char *datFile, char *model, char *attr, int attrSize, int * strncpy(section, rcbuf+1, sizeof(section)); /* found new section */ 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)) + if ((strcasecmp(model, section) == 0) || + (section[0] == 'h' && + section[1] == 'p' && + section[2] == '_' && + strcasecmp(model, section + 3) == 0) || + (n > model_len && + strncasecmp(section, model, model_len) == 0 && + strncasecmp(section + model_len, "_series", strlen("_series") == 0) + ) + ) { /* Found model match. */ *bytes_read = ResolveAttributes(fp, attr, attrSize);