Project

General

Profile

Actions

Bug #987

open

Incomplete string comparison pattern

Added by Mathieu Desnoyers almost 9 years ago. Updated over 8 years ago.

Status:
Confirmed
Priority:
Normal
Target version:
Start date:
01/06/2016
Due date:
% Done:

0%

Estimated time:

Description

In a few instances in lttng-tools, a string comparison pattern involving strncmp and strlen() to limit the length of the comparison is used.

One can quickly find them with:

grep -r -A 3 strncmp . | less -> search for strlen or strnlen

Many of those are OK: they indeed only want to match the beginning of the strings. However, this pattern is incorrectly used in cases where a full match is required, for instance:

ust-registry.c:ht_match_event()
./src/bin/lttng/commands/enable_channels.c: if (!strncmp(output_mmap, opt_output, strlen(output_mmap))) {
./src/bin/lttng/commands/enable_channels.c: } else if (!strncmp(output_splice, opt_output, strlen(output_splice))) {
./src/bin/lttng-sessiond/snapshot.c: if (!strncmp(output->name, name, strlen(name))) {

Actions

Also available in: Atom PDF