From 4cf01e2ecc5f78d4a9a12becd2bde6d2756f8072 Mon Sep 17 00:00:00 2001 From: Marcus Overhagen Date: Mon, 15 May 2006 18:43:36 +0000 Subject: [PATCH] Fixed off-by-one error that prevented finding nodes using wildcard names, like DVB* git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17467 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/media/NodeManager.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/servers/media/NodeManager.cpp b/src/servers/media/NodeManager.cpp index c650110d89..8f55e3cf7e 100644 --- a/src/servers/media/NodeManager.cpp +++ b/src/servers/media/NodeManager.cpp @@ -474,18 +474,17 @@ NodeManager::GetLiveNodes(Stack *livenodes, int32 maxcount, cons // determine the count of byte to compare when checking for a name with(out) wildcard if (name) { namelen = strlen(name); - if (name[namelen] == '*') + if (namelen > 0 && name[namelen - 1] == '*') namelen--; // compares without the '*' - else - namelen++; // also compares the terminating NULL - } else + } else { namelen = 0; + } for (fRegisteredNodeMap->Rewind(); (maxcount > 0) && fRegisteredNodeMap->GetNext(&rn); ) { if ((rn->kinds & require_kinds) != require_kinds) continue; if (namelen) { - if (0 != memcmp(name, rn->name, namelen)) + if (0 != strncmp(name, rn->name, namelen)) continue; } if (inputformat) { @@ -746,12 +745,11 @@ NodeManager::GetDormantNodes(dormant_node_info * out_info, // determine the count of byte to compare when checking for a name with(out) wildcard if (name) { namelen = strlen(name); - if (name[namelen] == '*') + if (namelen > 0 && name[namelen - 1] == '*') namelen--; // compares without the '*' - else - namelen++; // also compares the terminating NULL - } else + } else { namelen = 0; + } maxcount = *io_count; *io_count = 0; @@ -767,7 +765,7 @@ NodeManager::GetDormantNodes(dormant_node_info * out_info, if ((dfi->kinds & deny_kinds) != 0) continue; if (namelen) { - if (0 != memcmp(name, dfi->name, namelen)) + if (0 != strncmp(name, dfi->name, namelen)) continue; } if (has_input) {