path: root/src
AgeCommit message (Collapse)AuthorFiles
2019-04-08Preserve locking type during database reorganizationSergey Poznyakoff1
* src/recover.c (_gdbm_finish_transfer): Preserve locking type.
2018-10-18Restore backward compatibility with older databasesSergey Poznyakoff1
* src/gdbmopen.c (validate_header): Silently accept databases with next_block pointing beyond end of file.
2018-10-18Attempt recovery in case of invalid next_block header fieldSergey Poznyakoff4
* src/gdbmopen.c (validate_header): Return GDBM_NEED_RECOVERY if next_block is invalid. (_gdbm_validate_header): New function. (gdbm_fd_open): Set need_recovery depending on return from validate_header. (gdbm_open): Bail out on invalid value of GDBM_OPENMASK bits. * src/proto.h (_gdbm_validate_header): New proto. * src/recover.c (check_db): Re-validate the header. * src/gdbmtool.c (export_handler): Fix option processing.
2018-08-31Various bugfixes.Sergey Poznyakoff11
* compat/dbmopen.c (ndbm_open_dir_file0): Ignore ENOENT. * src/falloc.c (push_avail_block): Free temporary storage no matter what return status. * src/ (GDBM_FILE_TRUNCATE_ERROR): New error code. * src/gdbmdump.c (_gdbm_dump_ascii): Initialize rc. * src/gdbmerrno.c: Handle new error.code * src/gdbmload.c (gdbm_load_bdb_dump): Initialize rc * src/gdbmopen.c (_gdbm_ftruncate): New function. (gdbm_fd_open): Use _gdbm_ftruncate. Check its return. * src/gdbmseq.c (gdbm_firstkey): Initialize dsize * src/gdbmtool.c (command_generator): Check if cmd is NULL. (shouldn't happen, but anyways). * src/mmap.c (_gdbm_mapped_lseek): Check for vailidity of the 'whence' parameter. * src/systems.h (TRUNCATE): Remove macro. * src/util.c (vgetyn): Remove unnecessary assignment.
2018-08-19Fix directory entry validation.Sergey Poznyakoff1
Bug reported by Miroslav Lichvar and Marek Skalick√Ĺ * src/bucket.c (gdbm_dir_entry_valid_p): Fix lower limit for the allowed bucket address. Initial allocation of second block for the directory can be eventually returned to the available list when the directory is expanded during bucket splitting.
2018-08-12BugfixSergey Poznyakoff2
* src/gdbmdump.c (_gdbm_dump_ascii): Clear the GDBM_ITEM_NOT_FOUND error. * src/gdbmexp.c (gdbm_export_to_file): Likewise. * NEWS: Update.
2018-08-03BugfixSergey Poznyakoff1
* src/gdbmopen.c (gdbm_avail_table_valid_p): Fix improper use of the GDBM_DEBUG macro.
2018-07-31BugfixSergey Poznyakoff1
* src/gdbmsync.c (gdbm_sync): Always return a meaningful value
2018-07-02BugfixesSergey Poznyakoff2
* src/recover.c (backup_name): Fix memory overwrite. * src/gdbmtool.c (recover_handler): New option "force".
2018-07-01Change return value of gdbm_close and gdbm_syncSergey Poznyakoff6
* src/ (gdbm_close, gdbm_sync): Return int (GDBM_FILE_CLOSE_ERROR, GDBM_FILE_SYNC_ERROR): New error codes. * src/gdbmclose.c (gdbm_close): Return 0 on success, -1 on failure. Set gdbm_errno and errno. * src/gdbmsync.c (gdbm_sync): Likewise. * src/gdbmerrno.c: Handle new error codes. * src/mmap.c (_gdbm_mapped_sync): Set gdbm_errno. * src/proto.h (gdbm_file_sync): Set gdbm_errno. * doc/gdbm.3: Document changes. * doc/gdbm.texi: Document changes. * NEWS: Document changes. * Set patchlevel. * tests/ Add new test. * tests/ Add new test. * tests/ New test case. * tests/closerr.c: New test program. * tests/gtdel.c: Check gdbm_close return. * tests/gtdump.c: Likewise. * tests/gtfetch.c: Likewise. * tests/gtload.c: Likewise. * tests/gtopt.c: Likewise. * tests/gtrecover.c: Likewise.
2018-06-27New gdbmtool variables: coalesce and centfreeSergey Poznyakoff2
The two boolean variables control the use of free block coalescing and central free block modes in newly opened databases.
2018-06-27Coalesce mode: take into account both left- and right-adjacent slots.Sergey Poznyakoff1
* src/falloc.c (avail_lookup): Remove the start parameter. (avail_move): Take pointer to the count of entries in av_table. Update the pointed to value after performing the move. All uses changed. (_gdbm_put_av_elem): Rewrite the "can_merge" loop.
2018-06-25Optimize operations on avail lists.Sergey Poznyakoff1
Use binary search for look-ups. * src/falloc.c (avail_lookup, avail_move): New functions. (get_elem): Use avail_lookup to search. (_gdbm_put_av_elem): Use avail_lookup and avail_move to handle the avail table. In coalesce mode, store the index of the greater than or equal entry to avoid extra lookup in case no suitable entry is found.
2018-06-23Bugfixes. Consistently use the coalesce_blocks flag.Sergey Poznyakoff3
* src/bucket.c (_gdbm_split_bucket): Take into account coalesce_blocks * src/falloc.c (_gdbm_put_av_elem): Change to void return. All uses changed. * src/proto.h: Likewise.
2018-06-23Fix the previous patchSergey Poznyakoff1
2018-06-23Silently restore sorting order of avail array when checking it.Sergey Poznyakoff2
* src/gdbmdefs.h (gdbm_avail_table_valid_p): Remove const qualifier from the AV parameter. * src/gdbmopen.c (gdbm_avail_table_valid_p): Don't insist on proper ordering of the array. Restore it if neccessary.
2018-06-23Maintain correct ordering of the avail table after coalescing.Sergey Poznyakoff1
* src/falloc.c (_gdbm_put_av_elem): Float the merged entry to its proper position to preserve the sorting order. * THANKS: Thanks Adam Sampson
2018-06-23Fix typoSergey Poznyakoff1
2018-06-16Version 1.5v1.15Sergey Poznyakoff6
* Version 1.5 * NEWS: Update. * src/ (VI_CURRENT): Increment to 6 * src/bucket.c (_gdbm_get_bucket): Fix the upper limit for bucket_bits. * src/falloc.c (push_avail_block): Fill the allocated block with 0s.
2018-05-30More error checkingSergey Poznyakoff2
* src/bucket.c (_gdbm_get_bucket): Check if bucket_bits value is valid. * src/gdbmtool.c (_gdbm_print_avail_list): Reverse the sense of the conditional (fix regression).
2018-05-30Avoid unnecessary memory reallocations during cachingSergey Poznyakoff4
* src/findkey.c (_gdbm_read_entry): Reallocate cache_entry->ca_data.dptr only if necessary. * src/gdbmdefs.h (data_cache_elem): New member: dsize * src/gdbmdelete.c: Don't free cache_entry->ca_data.dptr * src/gdbmopen.c (_gdbm_init_cache): Initialize ca_data.dsize
2018-05-30Rewrite gdbm_file_write etc. as inline functions.Sergey Poznyakoff1
2018-05-30Fix the legacy operation (--disable-mmapped-io)Sergey Poznyakoff6
* src/mmap.c (_gdbm_file_extend): Move to ... * src/fullio.c: ... here * src/proto.h (_gdbm_file_extend): New proto. * src/gdbmopen.c (gdbm_fd_open): Make sure the file size equals header->next_block. * src/gdbmsetopt.c [!HAVE_MMAP]: Don't disable GDBM_GETFLAGS. * src/update.c (_gdbm_end_update): Make sure disk file ends on header->next_block.
2018-05-30Namespace cleanupSergey Poznyakoff14
Rename: __read to gdbm_file_read __write to gdbm_file_write __lseek to gdbm_file_seek __fsync to gdbm_file_sync
2018-05-30Drop debugging hooksSergey Poznyakoff9
The hooks were introduced as a temporary tool in de7834e9. They did their job and are not necessary any more.
2018-05-30gdbmtool: bugfixesSergey Poznyakoff1
* src/gdbmtool.c (print_bucket_begin): Check return value from _gdbm_get_bucket. (source_handler): Don't gtry to push NULL stream.
2018-05-30Fix memory leak in _gdbm_get_bucketSergey Poznyakoff3
2018-05-30Fix memory leaks in handling history (gdbmtool) and in gdbm_recoverSergey Poznyakoff3
2018-05-29Minor changesSergey Poznyakoff1
* src/gdbmtool.c: Reduce memory consuption in -random mode. Some minor bugfixes as well.
2018-05-27Additional validation of avail_table.Sergey Poznyakoff8
Verify that avail_table is sorted by size and that each element's size falls within allowed range. * src/bucket.c (gdbm_get_bucket): Fix bucket validation. Validate bucket_avail. (_gdbm_split_bucket): Check return from _gdbm_free. * src/falloc.c (adjust_bucket_avail,_gdbm_free): Return error code. All uses updated. (pop_avail_block): Fix eventual memory leak. Use gdbm_avail_block_validate. * src/gdbmdefs.h (gdbm_avail_table_valid_p): Change signature. * src/gdbmopen.c (gdbm_avail_table_valid_p): Traverse the array verifying address and size of each element. (gdbm_avail_block_validate) (gdbm_bucket_avail_table_validate): New functions. (validate_header): Remove call to gdbm_avail_block_valid_p. Avail_block is validated later, after it's been loaded. Bail out if header->next_block does not equal the file size. (gdbm_fd_open): Validate avail_block. * src/gdbmstore.c (_gdbm_store): Check return from _gdbm_free. Avoid endless loop in case of inconsistent h_table. * src/gdbmtool.c (_gdbm_print_avail_list): Use gdbm_avail_block_validate. * src/proto.h: Update. * tests/gtload.c: Improve error diagnostics.
2018-05-26gdbmtool: quote special characters in command line inputSergey Poznyakoff1
2018-05-25More database consistency checksSergey Poznyakoff9
* NEWS: Update. * THANKS: Update. * src/bucket.c (_gdbm_get_bucket): Check if directory entry is valid. Don't cache invalid buckets. * src/ (GDBM_BAD_DIR_ENTRY): New error code. * src/gdbmerrno.c: Likewise. * src/gdbmopen.c (validate_header): Compute expected number of bucket elements based on the bucket size, not on the block size. (_gdbm_init_cache_entry): New function. * src/proto.h (_gdbm_init_cache_entry): New proto. * src/recover.c (gdbm_recover): Clear error state after return from check_db indicating failure.
2018-05-24Various fixesSergey Poznyakoff6
* src/input-std.c: Bugfix * doc/gdbm.texi: Document changes. * README: Update. * New option --enable-gdbmtool-debug. * src/ Conditionally augment AM_YFLAGS and AM_LFLAGS with options that enable debugging. * src/gdbmtool.c: Conditionally enable --lex-trace and --gram-trace options. * src/gram.y: Likewise. * src/lex.l: Likewise. * tests/ Remove architecure-dependent tests. * tests/ Likewise.
2018-05-24More input checking fixesSergey Poznyakoff4
* src/gdbmdefs.h (gdbm_avail_block_valid_p): Minimal capacity of an avail_block is 1 (one entry is stored in the block itself). * src/gdbmopen.c (gdbm_avail_table_valid_p): New function. (validate_header): Fix verification of dir_size and dir_bits. Verify avail.size. * src/falloc.c (pop_avail_block): Use gdbm_avail_table_valid_p * src/gdbmtool.c (_gdbm_print_avail_list): Likewise.
2018-05-24More error checking; improve gdbm_recoverSergey Poznyakoff8
* (set-dist-date): New rule (dist-hook): Catch FIXMEs in NEWS. * NEWS: Updated. * src/findkey.c (gdbm_bucket_element_valid_p): New function. (_gdbm_read_entry): Validate the retrieved bucket element. * src/ (gdbm_recovery): New member: duplicate_keys. (GDBM_BAD_HASH_TABLE): New error code. * src/gdbmdefs.h (TYPE_WIDTH,SIGNED_TYPE_MAXIMUM) (OFF_T_MAX): New defines. (off_t_sum_ok): New function. (gdbm_bucket_element_valid_p): New prototype. * src/gdbmerrno.c: Support for GDBM_BAD_HASH_TABLE code. * src/gdbmtool.c (recover_handler): Fix argument counting. New argument 'summary' prints statistics summary at the end of the run. (export_handler,import_handler): Fix argument counting. * src/mmap.c (SUM_FILE_SIZE): Rewrite as inlined function. Add error checking. (_gdbm_mapped_remap): More error checking. * src/recover.c (run_recovery): Don't bail out on GDBM_CANNOT_REPLACE. (gdbm_recover): Initialize duplicate_keys * src/systems.h: Include limits.h
2018-05-24Fix the use of return code from _gdbm_full_(read|write) functionsSergey Poznyakoff5
2018-05-24error checking: check for avail_block consistency before using itSergey Poznyakoff6
* src/gdbmdefs.h (gdbm_avail_block_valid_p): New function. * src/ (GDBM_BAD_AVAIL): New error code. * src/gdbmerrno.c: Support new error code. * src/falloc.c (pop_avail_block): Validate the avail_block * src/gdbmopen.c (validate_header): Validate the avail_block. * src/gdbmtool.c (_gdbm_avail_list_size) (_gdbm_print_avail_list): Validate the avail_block.
2018-05-24gdbmtool: fix data conversion when storing structured content.Sergey Poznyakoff1
* src/datconv.c (DEFNSCAN): Use proper target type to store in datum. (datum_scan_notag): Accept C-like initialization of array of characters by a quoted string.
2018-05-23gdbmtool: accept commands from command line as well as from fileSergey Poznyakoff9
Commands can be supplied to gdbmtool in three ways: 1. From a file, using the --file (-f) option: gdbmtool -f comfile 2. From the command line, if first argument is the database name: gdbmtool test.db count \; fetch mykey \; avail Note the use of semicolon to delimit commands. 3. From the interactive shell, if neither of the above is used. * src/ Add new sources. * src/gdbmtool.c: Use new stream functions for input. * src/gdbmtool.h (setsource): Remove proto. (instream_t): New data type. (instream_name, instream_read) (instream_close, instream_interactive) (instream_eq): New functions. (instream_stdin_create) (instream_argv_create) (instream_file_create) (interactive, input_context_push): New protos. * src/gram.y: Accept ; in place of newline. * src/input-argv.c: New file. * src/input-file.c: New file. * src/input-rl.c: Rewrite to provide instream_t API. * src/input-std.c: Likewise. * src/lex.l: Rewrite. * tests/.gitignore: Update. * tests/ Add new tests. Incorporate DejaGNU tests. * tests/config/default.exp: New file. * tests/gdbmtool/base.exp: New file. * tests/ New file. * tests/ New file. * tests/ New file. * tests/ Include new tests.
2018-05-19Catch more errorsSergey Poznyakoff3
* src/gdbmdump.c (_gdbm_dump_ascii): Break on errors * src/gdbmopen.c (compute_directory_size): Remove unused argument. (validate_header): Catch dir_size and dir_bits mismatches. * src/mmap.c (_gdbm_mapped_lseek): Bail out on negative offsets. * tests/ New test. * tests/ New test. * tests/ Add new tests. * tests/ Add new tests.
2018-05-19Add new testsSergey Poznyakoff1
* src/gdbm_dump.c: Fix exit code. * Determine presence of gzip and base64 (GZIP_BIN,BASE64_BIN): New variables. * tests/ (GZIP_BIN,BASE64_BIN): New variables. * tests/ New file. * tests/ New file. * tests/ New file. * tests/ Add new tests. * tests/ Add new tests.
2018-05-19Improve error checkingSergey Poznyakoff8
* src/bucket.c (_gdbm_get_bucket): Improve validation. * src/fullio.c (_gdbm_full_read,_gdbm_full_write): Don't overwrite an already set error. * src/ (GDBM_WRONG_OFF_T): Merge with GDBM_BAD_FILE_OFFSET. (GDBM_BAD_HEADER): New error code. * src/gdbmdump.c (_gdbm_dump_ascii): Check for database error code. * src/gdbmerrno.c (gdbm_errlist): Add GDBM_BAD_HEADER * src/gdbmopen.c (validate_header: Imporve logic. (_gdbm_init_cache): Initialize bucket_cache * src/gdbmseq.c (gdbm_firstkey): Check return value from _gdbm_get_bucket. * src/mmap.c (_gdbm_mapped_remap): Bail out if current position is bigger than file size.
2018-05-19Fix typoSergey Poznyakoff1
2018-05-16Improve database file safety checks.Sergey Poznyakoff4
* src/bucket.c (_gdbm_get_bucket): Verify bucket consistency. * src/ (GDBM_BAD_BUCKET, GDBM_WRONG_ARCH): New error codes. * src/gdbmerrno.c (gdbm_errlist): New error codes. * src/gdbmopen.c (gdbm_fd_open): Improve header consistency checks.
2018-01-03Bump library current version numberv1.14.1Sergey Poznyakoff1
2018-01-01Happy GNU YearSergey Poznyakoff53
2017-12-23Fix build with --enable-gdbm-exportSergey Poznyakoff1
* THANKS: Add Jakub Bogusz * export/export.c: Define GDBM_EXPORT_18 prior to including gdbmexp.c * src/gdbmexp.c [GDBM_EXPORT_18]: Define GDBM_SET_ERRNO and GDBM_ASSERT_CONSISTENCY.
2017-12-23BugfixSergey Poznyakoff1
* src/gdbmsetopt.c: Ignore NULL entries
2017-12-23Complement c175231eSergey Poznyakoff1
* Check whether __thread qualifier is supported * src/gdbmerrno.c (gdbm_errno_storage): Use GDBM_THREAD_LOCAL instead of __thread.
2017-12-21Improve database reproducibilitySergey Poznyakoff3
* src/gdbmopen.c (gdbm_fd_open): Fill allocated memory with 0's where necessary. Check return value from fstat. * src/mmap.c (_gdbm_file_size): Set errno here, instead of delegating that to the caller. (_gdbm_file_extend): New function. (_gdbm_mapped_remap): Call _gdbm_file_extend instead of leaving the newly allocated space filled with garbage. * src/gdbmload.c (_set_gdbm_meta_info): Additional error checking. * NEWS: Update.

Return to:

Send suggestions and report system problems to the System administrator.