tiffset size limitation
This code is buggy:
text = (char *) malloc(1000000);
if(text == NULL) {
fprintf( stderr,
"Memory allocation error\n");
fclose( fp );
continue;
}
len = fread( text, 1, 999999, fp );
text[len] = '\0';
You can't set a string more than 1000000 bytes. At the very least, this code should check the file size and allocate an appropriate size, failing if that's not possible, rather than silent truncation.
It would also be worthwhile looking at API additions to permit streaming writes and reads of large values, so they don't need fully buffering in memory.