]> git.ipfire.org Git - thirdparty/systemd.git/commit
libsystemd-network: make option_append() atomic and make the code a bit clearer
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 3 Aug 2019 14:49:39 +0000 (16:49 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 3 Aug 2019 15:36:38 +0000 (17:36 +0200)
commitbc67342e94ce1133af6d24c2d05c6c2ee5c92bdb
treef13685eaab5ac1f46c45a0c3e7067787c5b5955d
parent10b1d42e579ae1ca6e022b61c3e5a44e1f3f2b80
libsystemd-network: make option_append() atomic and make the code a bit clearer

Comparisons are done in the normal order (if (need > available), not if (available < need)),
variables have reduced scope and are renamed for clarity.

The only functional change is that if we return -ENAMETOOLONG, we do that
without modifying the options[] array.

I also added an explanatory comment. The use of one offset to point into three
buffers is not obvious.

Coverity (in CID#1402354) says that sname might be accessed at bad offset, but
I cannot see this happening. We check for available space before writing anything.
src/libsystemd-network/dhcp-option.c