Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ using cdb_read returns extra characters on some reads
    primarykey
    data
    text
    <p>I am using the following function to loop through a couple of open CDB hash tables. Sometimes the value for a given key is returned along with an additional character (specifically a CTRL-P (a DLE character/0x16/0o020)). </p> <p>I have checked the cdb key/value pairs with a couple of different utilities and none of them show any additional characters appended to the values.</p> <p>I get the character if I use cdb_read() or cdb_getdata() (the commented out code below).</p> <p>If I had to guess I would say I am doing something wrong with the buffer I create to get the result from the cdb functions.</p> <p>Any advice or assistance is greatly appreciated. </p> <pre><code>char* HashReducer::getValueFromDb(const string &amp;id, vector &lt;struct cdb *&gt; &amp;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,&amp;hex_len); char *value = NULL; vector &lt;struct cdb *&gt;::iterator my_iter = myHashFiles.begin(); vector &lt;struct cdb *&gt;::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 &amp;&amp; !value ; my_iter++) { //cerr &lt;&lt; "\n looking for this MD5:" &lt;&lt; id &lt;&lt; " hex(" &lt;&lt; hex_value &lt;&lt; ") \n"; if (cdb_find(*my_iter, hex_value, hex_len)){ //cerr &lt;&lt; "\n\nI found the key " &lt;&lt; id &lt;&lt; " and it is " &lt;&lt; cdb_datalen(*my_iter) &lt;&lt; " 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 &lt;&lt; "\n\nThe value is:" &lt;&lt; value &lt;&lt; " len is:" &lt;&lt; strlen(value)&lt;&lt; "\n\n"; }; } } catch (...){} return value; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload