]> git.ipfire.org Git - thirdparty/systemd.git/commit
network: fix a potential divide-by-zero (#37705)
authorAlex <alexguo1023@gmail.com>
Mon, 2 Jun 2025 22:47:49 +0000 (18:47 -0400)
committerLuca Boccassi <luca.boccassi@gmail.com>
Wed, 25 Jun 2025 12:36:10 +0000 (13:36 +0100)
commite2c9fdd5c0f84eb234e122fe8fce9c4d949882cd
tree2cfb83059d1bc5a6caf015fb4ad8953dea0be0d6
parentddddef495d7f59db6040d89336c1eeccc7251fce
network: fix a potential divide-by-zero (#37705)

In function `tc_init`, hz is parsed from the content of file
`"/proc/net/psched"` and can be 0.
In function `hierarchy_token_bucket_class_verify`, hz is directly used
as a divisor in
`htb->buffer = htb->rate / hz + htb->mtu;` without any check. This adds a check on hz before using it as a divisor.

Co-authored-by: jinyaoguo <guo846@purdue.edu>
(cherry picked from commit 1a596054a0f937bfc244580f07510759a0e45657)
src/network/tc/htb.c