Skip to content

Commit 9c30786

Browse files
committed
lua: Fix off by 1 test for hostname termination
1 parent 6a46dff commit 9c30786

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/plugins/lua.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ lua_run_lookup_addr(struct plugin *p, struct svc_ctx *sctx, const void *data,
328328
if (lua_rawgeti(L, -1, 2) == LUA_TNUMBER)
329329
ltime = (uint32_t)lua_tonumber(L, -1);
330330
if (lua_rawgeti(L, -2, 1) != LUA_TSTRING) {
331+
logerrx("%s: lookup_addr: not a string", lua_name);
331332
errno = EINVAL;
332333
goto out;
333334
}
@@ -886,7 +887,8 @@ lua_lookup_hostname(struct plugin *p, char *hostname, const struct bootp *bootp,
886887
return -1;
887888
if (hnamelen == 0)
888889
return 0;
889-
if (hnamelen > DHCP_HOSTNAME_LEN || ((char *)hname)[hnamelen] != '\0') {
890+
if (hnamelen > DHCP_HOSTNAME_LEN ||
891+
((char *)hname)[hnamelen - 1] != '\0') {
890892
errno = EINVAL;
891893
return -1;
892894
}

0 commit comments

Comments
 (0)