@@ -163,14 +163,12 @@ static int kvm_open_vcpu_dir(struct kvm_clock_sync *kvm, int cpu, char *dir_str)
goto error;
while ((entry = readdir(dir))) {
if (entry->d_type != DT_DIR) {
- if (!strncmp(entry->d_name, KVM_DEBUG_OFFSET_FILE,
- strlen(KVM_DEBUG_OFFSET_FILE))) {
+ if (!strcmp(entry->d_name, KVM_DEBUG_OFFSET_FILE)) {
snprintf(path, sizeof(path), "%s/%s",
dir_str, entry->d_name);
kvm->vcpu_offsets[cpu] = strdup(path);
}
- if (!strncmp(entry->d_name, KVM_DEBUG_SCALING_FILE,
- strlen(KVM_DEBUG_SCALING_FILE))) {
+ if (!strcmp(entry->d_name, KVM_DEBUG_SCALING_FILE)) {
snprintf(path, sizeof(path), "%s/%s",
dir_str, entry->d_name);
kvm->vcpu_scalings[cpu] = strdup(path);
Using strncmp() when looking for KVM debug files with given names in the debugfs is useless and could be dangerous, strcmp() should be used instead. Limiting the string compare to the name of the searched file only could bring problems, in case of files with overlapping names. Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com> --- lib/trace-cmd/trace-timesync-kvm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)