all repos — fluxbox @ 7b8fd2d81ad80a73564fc9fbb779f47568f12652

custom fork of the fluxbox windowmanager

Fix bug: integer underflow in startup phase

When fluxbox comes up some of it's drawables span a 1x1 area. Subtracting from
such small numbers bigger ones always lead to massive problems when 'unsigned
int' are involved:

'button_width' is an unsigned int of '1' (this might be caused by another
issue or on purpose, anyway), subtracting -10 or any other number should
result in something < 0 when in reality an integer underflow happen: max_width
is now MAX_INT-something big. This makes fluxbox crash under certain
circumstances.

This fixes bug #1116.
Mathias Gumz akira@fluxbox.org
commit

7b8fd2d81ad80a73564fc9fbb779f47568f12652

parent

d8c11d0852d889f4df23c9398463aa3848e0e7c7

1 files changed, 7 insertions(+), 1 deletions(-)

jump to
M src/FbTk/TextButton.ccsrc/FbTk/TextButton.cc

@@ -143,11 +143,17 @@ const FbString& visual = text().visual();

unsigned int textlen = visual.size(); unsigned int button_width = width(); unsigned int button_height = height(); + const int max_width = static_cast<int>(button_width) - x_offset - + m_left_padding - m_right_padding; + + if (max_width <= bevel()) { + return; + } translateSize(m_orientation, button_width, button_height); // horizontal alignment, cut off text if needed - int align_x = FbTk::doAlignment(button_width - x_offset - m_left_padding - m_right_padding, + int align_x = FbTk::doAlignment(max_width, bevel(), justify(), font(), visual.data(), visual.size(), textlen); // return new text len