Skip to content

dahdi-base: fix potential underflow of unsigned type #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions drivers/dahdi/dahdi-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -5380,7 +5380,7 @@ static int dahdi_ioctl_get_version(unsigned long data)
{
struct dahdi_versioninfo vi;
struct ecfactory *cur;
size_t space = sizeof(vi.echo_canceller) - 1;
size_t space = sizeof(vi.echo_canceller) - 1, ec_name_len;
bool have_hwec = dahdi_any_hwec_available();

memset(&vi, 0, sizeof(vi));
Expand All @@ -5404,9 +5404,10 @@ static int dahdi_ioctl_get_version(unsigned long data)
}
strncat(vi.echo_canceller + strlen(vi.echo_canceller),
ec_name, space);
space -= strlen(ec_name);
if (space < 1)
ec_name_len = strlen(ec_name);
if (ec_name_len > space + 1)
break;
space -= ec_name_len;
if (cur->list.next && (cur->list.next != &ecfactory_list)) {
strncat(vi.echo_canceller + strlen(vi.echo_canceller),
", ", space);
Expand Down