次の関数を使用して、いくつかの開いている CDB ハッシュ テーブルをループしています。特定のキーの値が追加の文字 (具体的には CTRL-P (DLE 文字/0x16/0o020)) と共に返されることがあります。
いくつかの異なるユーティリティを使用して cdb のキーと値のペアを確認しましたが、値に追加の文字が追加されているものはありません。
cdb_read() または cdb_getdata() (以下のコメントアウトされたコード) を使用すると、文字が取得されます。
推測する必要がある場合は、cdb 関数から結果を取得するために作成したバッファーに何か問題があると言えます。
アドバイスや支援をいただければ幸いです。
char* HashReducer::getValueFromDb(const string &id, vector <struct cdb *> &myHashFiles)
{
unsigned char hex_value[BUFSIZ];
size_t hex_len;
//construct a real hex (not ascii-hex) value to use for database lookups
atoh(id,hex_value,&hex_len);
char *value = NULL;
vector <struct cdb *>::iterator my_iter = myHashFiles.begin();
vector <struct cdb *>::iterator my_end = myHashFiles.end();
try
{
//while there are more databases to search and we have not found a match
for(; my_iter != my_end && !value ; my_iter++)
{
//cerr << "\n looking for this MD5:" << id << " hex(" << hex_value << ") \n";
if (cdb_find(*my_iter, hex_value, hex_len)){
//cerr << "\n\nI found the key " << id << " and it is " << cdb_datalen(*my_iter) << " long\n\n";
value = (char *)malloc(cdb_datalen(*my_iter));
cdb_read(*my_iter,value,cdb_datalen(*my_iter),cdb_datapos(*my_iter));
//value = (char *)cdb_getdata(*my_iter);
//cerr << "\n\nThe value is:" << value << " len is:" << strlen(value)<< "\n\n";
};
}
}
catch (...){}
return value;
}