From d5720ee85eb64a8e78254e289b2d8e224c705736 Mon Sep 17 00:00:00 2001 From: Iustin Pop Date: Sun, 13 Oct 2019 20:14:39 +0200 Subject: [PATCH] Fix stinit file parsing broken in 874d58d9 For some reason I missed this during the pull request (even if trivial), thanks travis-ci for letting me know (indirectly :). Fixes #14. --- stinit.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/stinit.c b/stinit.c index 4b532f3..eec4a8c 100644 --- a/stinit.c +++ b/stinit.c @@ -316,6 +316,7 @@ find_pars(FILE *dbf, char *company, char *product, char *rev, devdef_tr *defs, i SKIP_WHITE(comptr); for (; *nextdef != '\0';) { + int tmpsize; curdef = nextdef; SKIP_WHITE(curdef); for (nextdef++; @@ -334,7 +335,14 @@ find_pars(FILE *dbf, char *company, char *product, char *rev, devdef_tr *defs, i continue; } - snprintf(defstr, sizeof(defstr) / sizeof(char), "%s%s", comptr, cp); + if ((tmpsize = snprintf(modebuf, DEFMAX, "%s%s", comptr, cp)) >= DEFMAX) { + fprintf(stderr, "Definition too large for ('%s', '%s', '%s'): size %d, maximum is %d\n", + tmpcomp, tmpprod, tmprev, tmpsize, DEFMAX); + *nextdef = c; + errors++; + continue; + } + *nextdef = c; if (verbose > 1)