projects
/
project
/
odhcpd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9830e5e
)
statefiles: fix off-by-one-bug
author
David Härdeman
<
[email protected]
>
Sun, 23 Nov 2025 18:34:51 +0000
(19:34 +0100)
committer
Álvaro Fernández Rojas
<
[email protected]
>
Sun, 23 Nov 2025 19:04:00 +0000
(20:04 +0100)
The string with the final hostsfile name is "%s.%s", so we need two
extra bytes for the separating "." and for the trailing null byte.
Signed-off-by: David Härdeman <
[email protected]
>
Link:
https://github.com/openwrt/odhcpd/pull/322
Signed-off-by: Álvaro Fernández Rojas <
[email protected]
>
src/statefiles.c
patch
|
blob
|
history
diff --git
a/src/statefiles.c
b/src/statefiles.c
index ed45f5559dc061b33bfd35073d0ab79833d51a81..a5d4e3ea6aeb8bd3e55594706901b37a814e13f0 100644
(file)
--- a/
src/statefiles.c
+++ b/
src/statefiles.c
@@
-103,7
+103,7
@@
static void statefiles_write_hosts(time_t now)
avl_for_each_element(&interfaces, ctxt.iface, avl) {
char *hostsfile;
- hostsfile = alloca(strlen(ODHCPD_HOSTS_FILE_PREFIX) + strlen(ctxt.iface->name) + 1);
+ hostsfile = alloca(strlen(ODHCPD_HOSTS_FILE_PREFIX) +
1 +
strlen(ctxt.iface->name) + 1);
sprintf(hostsfile, "%s.%s", ODHCPD_HOSTS_FILE_PREFIX, ctxt.iface->name);
fd = openat(config.dhcp_hostsdir_fd, tmp_hostsfile, O_CREAT | O_WRONLY | O_CLOEXEC, 0644);