dahdi-linux icon indicating copy to clipboard operation
dahdi-linux copied to clipboard

Dahdi-linux: Improper use of string operations

Open pprindeville opened this issue 7 months ago • 1 comments

I'm looking at various string constructs in (for example) drivers/dahdi/dahdi-base.c:

strncat(vi.echo_canceller + strlen(vi.echo_canceller),
        ec_name, space);

which doesn't make sense. strncat(s1, s2, n) already finds the strlen(s1) when doing the append. This is redundant. Either do:

strncat(vi.echo_canceller,
        ec_name, space);

or:

strncpy(vi.echo_canceller + strlen(vi.echo_canceller),
        ec_name, space);

pprindeville avatar Jun 03 '25 17:06 pprindeville

Is this the only improper string operation you found? Your comment seems to imply there may be multiple. I don't see other instances of this type of misusage though.

$ grep -R "strncat"
drivers/dahdi/dahdi-base.c:             strncat(vi.echo_canceller + strlen(vi.echo_canceller),
drivers/dahdi/dahdi-base.c:                     strncat(vi.echo_canceller + strlen(vi.echo_canceller),

InterLinked1 avatar Aug 02 '25 23:08 InterLinked1