Fix binary dump format for key and/or data of zero size
This commit is contained in:
parent
ed7010a44d
commit
35742a418e
61
Fix-binary-dump-format-for-key-and-or-data-of-zero-s.patch
Normal file
61
Fix-binary-dump-format-for-key-and-or-data-of-zero-s.patch
Normal file
@ -0,0 +1,61 @@
|
||||
From 94d0a6238e9573473d2cfdc74135305b2f6741f2 Mon Sep 17 00:00:00 2001
|
||||
From: Sergey Poznyakoff <gray@gnu.org>
|
||||
Date: Thu, 9 Jun 2022 22:44:26 +0300
|
||||
Subject: [PATCH] Fix binary dump format for key and/or data of zero size.
|
||||
|
||||
Fixes https://puszcza.gnu.org.ua/bugs/?565
|
||||
|
||||
* src/gdbmexp.c (gdbm_export_to_file): Check for positive size before
|
||||
attempting to write.
|
||||
* src/gdbmimp.c (gdbm_import_from_file): Check for positive size before
|
||||
attempting to read.
|
||||
---
|
||||
src/gdbmexp.c | 4 ++--
|
||||
src/gdbmimp.c | 4 ++--
|
||||
2 files changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/src/gdbmexp.c b/src/gdbmexp.c
|
||||
index 6646bba..6f20fe6 100644
|
||||
--- a/src/gdbmexp.c
|
||||
+++ b/src/gdbmexp.c
|
||||
@@ -65,13 +65,13 @@ gdbm_export_to_file (GDBM_FILE dbf, FILE *fp)
|
||||
size = htonl (key.dsize);
|
||||
if (fwrite (&size, sizeof (size), 1, fp) != 1)
|
||||
goto write_fail;
|
||||
- if (fwrite (key.dptr, key.dsize, 1, fp) != 1)
|
||||
+ if (key.dsize > 0 && fwrite (key.dptr, key.dsize, 1, fp) != 1)
|
||||
goto write_fail;
|
||||
|
||||
size = htonl (data.dsize);
|
||||
if (fwrite (&size, sizeof (size), 1, fp) != 1)
|
||||
goto write_fail;
|
||||
- if (fwrite (data.dptr, data.dsize, 1, fp) != 1)
|
||||
+ if (data.dsize > 0 && fwrite (data.dptr, data.dsize, 1, fp) != 1)
|
||||
goto write_fail;
|
||||
}
|
||||
|
||||
diff --git a/src/gdbmimp.c b/src/gdbmimp.c
|
||||
index be98ed7..73c0b74 100644
|
||||
--- a/src/gdbmimp.c
|
||||
+++ b/src/gdbmimp.c
|
||||
@@ -113,7 +113,7 @@ gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag)
|
||||
key.dsize = (int) size;
|
||||
|
||||
/* Read the data. */
|
||||
- if (fread (&rsize, sizeof (rsize), 1, fp) != 1)
|
||||
+ if (size > 0 && fread (&rsize, sizeof (rsize), 1, fp) != 1)
|
||||
{
|
||||
ec = GDBM_FILE_READ_ERROR;
|
||||
break;
|
||||
@@ -135,7 +135,7 @@ gdbm_import_from_file (GDBM_FILE dbf, FILE *fp, int flag)
|
||||
break;
|
||||
}
|
||||
}
|
||||
- if (fread (dbuffer, size, 1, fp) != 1)
|
||||
+ if (size > 0 && fread (dbuffer, size, 1, fp) != 1)
|
||||
{
|
||||
ec = GDBM_FILE_READ_ERROR;
|
||||
break;
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
Name: gdbm
|
||||
Version: 1.22
|
||||
Release: 3
|
||||
Release: 4
|
||||
Epoch: 1
|
||||
Summary: A library of database functions that work similar to the standard UNIX dbm
|
||||
License: GPLv3+
|
||||
@ -8,6 +8,7 @@ URL: http://www.gnu.org/software/gdbm/
|
||||
Source0: http://ftp.gnu.org/gnu/gdbm/gdbm-%{version}.tar.gz
|
||||
|
||||
Patch0: Fix-gdbmtool-import-command.patch
|
||||
Patch1: Fix-binary-dump-format-for-key-and-or-data-of-zero-s.patch
|
||||
|
||||
BuildRequires: gcc libtool gettext readline-devel
|
||||
|
||||
@ -99,6 +100,9 @@ fi
|
||||
%{_infodir}/*.info*
|
||||
|
||||
%changelog
|
||||
* Fri Jun 17 2022 wangzhiqiang <wangzhiqiang95@huawei.com> - 1:1.22-4
|
||||
- DESC: Fix binary dump format for key and or data of zero size
|
||||
|
||||
* Tue Mar 1 2022 yanglongkang <yanglongkang@h-partners.com> - 1.22-3
|
||||
- add info into the devel package to resolve the installation error
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user