From b33dc97c551b7909d512638f5bf4cdbc39240103 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Tue, 9 Oct 2018 21:56:06 +0100 Subject: [PATCH 1/2] Restore WRAPCC when building lua Replay commit a57fe552e8109a25a10bf5cad510e467b0d39519 ('app/lua/luac_cross: WRAPCC CC here, too (#2453)') lost in intervening updates. --- app/lua/luac_cross/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/lua/luac_cross/Makefile b/app/lua/luac_cross/Makefile index 9b9d987f8c..61433628af 100644 --- a/app/lua/luac_cross/Makefile +++ b/app/lua/luac_cross/Makefile @@ -47,7 +47,7 @@ DEPS := $(SRC:%.c=$(ODIR)/%.d) CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES) DFLAGS = $(CCFLAGS) $(DDEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES) -CC := gcc +CC := $(WRAPCC) gcc ECHO := echo From 45a5539c2a2c8bda95984bdd4bc076ddbadf0515 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Tue, 9 Oct 2018 22:08:41 +0100 Subject: [PATCH 2/2] cron: fix several parsing bugs Gobble excess whitespace before columns as well as after all columns */n parsing now always includes the minimum entry and goes from there, rather than having its phase be offset by the field's minimum value, which seemed odd. (That is, "*/k" with k > min is now equivalent to "min+0k,min+1k,..." rather than "1k-min,2k-min,...") Remove an entirely superfluous test of end in */n parsing (it was always true anyway and appears to have been accidental). --- app/modules/cron.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/app/modules/cron.c b/app/modules/cron.c index 9604801894..2ff16e119b 100644 --- a/app/modules/cron.c +++ b/app/modules/cron.c @@ -32,18 +32,23 @@ static size_t cronent_count = 0; static uint64_t lcron_parsepart(lua_State *L, char *str, char **end, uint8_t min, uint8_t max) { uint64_t res = 0; + + /* Gobble whitespace before potential stars; no strtol on that path */ + while (*str != '\0' && (*str == ' ' || *str == '\t')) { + str++; + } + if (str[0] == '*') { uint32_t each = 1; *end = str + 1; if (str[1] == '/') { each = strtol(str + 2, end, 10); - if (end != 0) if (each == 0 || each >= max - min) { return luaL_error(L, "invalid spec (each %d)", each); } } for (int i = 0; i <= (max - min); i++) { - if (((min + i) % each) == 0) res |= (uint64_t)1 << i; + if ((i % each) == 0) res |= (uint64_t)1 << i; } } else { uint32_t val; @@ -63,14 +68,17 @@ static uint64_t lcron_parsepart(lua_State *L, char *str, char **end, uint8_t min static int lcron_parsedesc(lua_State *L, char *str, struct cronent_desc *desc) { char *s = str; desc->min = lcron_parsepart(L, s, &s, 0, 59); - if (*s != ' ') return luaL_error(L, "invalid spec (separator @%d)", s - str); + if (*s != ' ' && *s != '\t') return luaL_error(L, "invalid spec (separator @%d)", s - str); desc->hour = lcron_parsepart(L, s + 1, &s, 0, 23); - if (*s != ' ') return luaL_error(L, "invalid spec (separator @%d)", s - str); + if (*s != ' ' && *s != '\t') return luaL_error(L, "invalid spec (separator @%d)", s - str); desc->dom = lcron_parsepart(L, s + 1, &s, 1, 31); - if (*s != ' ') return luaL_error(L, "invalid spec (separator @%d)", s - str); + if (*s != ' ' && *s != '\t') return luaL_error(L, "invalid spec (separator @%d)", s - str); desc->mon = lcron_parsepart(L, s + 1, &s, 1, 12); - if (*s != ' ') return luaL_error(L, "invalid spec (separator @%d)", s - str); + if (*s != ' ' && *s != '\t') return luaL_error(L, "invalid spec (separator @%d)", s - str); desc->dow = lcron_parsepart(L, s + 1, &s, 0, 6); + while (*s != '\0' && (*s == ' ' || *s == '\t')) { + s++; + } if (*s != 0) return luaL_error(L, "invalid spec (trailing @%d)", s - str); return 0; }