48 lines
1.4 KiB
Diff
48 lines
1.4 KiB
Diff
|
|
From f34030816d84dfbf52f259404b32b81e53c21fbb Mon Sep 17 00:00:00 2001
|
||
|
|
From: Jes Sorensen <jsorensen@fb.com>
|
||
|
|
Date: Fri, 3 Apr 2020 14:09:18 -0400
|
||
|
|
Subject: [PATCH] rpmfiArchiveRead() use signed return value to handle -1 on
|
||
|
|
error
|
||
|
|
|
||
|
|
size_t is unsigned, so returning -1 is not going to have the expected
|
||
|
|
behavior. Fix it to return ssize_t.
|
||
|
|
|
||
|
|
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
|
||
|
|
---
|
||
|
|
lib/rpmarchive.h | 4 ++--
|
||
|
|
lib/rpmfi.c | 2 +-
|
||
|
|
2 files changed, 3 insertions(+), 3 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/lib/rpmarchive.h b/lib/rpmarchive.h
|
||
|
|
index c864e5b56..2484b4d71 100644
|
||
|
|
--- a/lib/rpmarchive.h
|
||
|
|
+++ b/lib/rpmarchive.h
|
||
|
|
@@ -122,9 +122,9 @@ int rpmfiArchiveWriteFile(rpmfi fi, FD_t fd);
|
||
|
|
* @param fi file info
|
||
|
|
* @param buf pointer to buffer
|
||
|
|
* @param size number of bytes to read
|
||
|
|
- * @return bytes actually read
|
||
|
|
+ * @return bytes actually read, -1 on error
|
||
|
|
*/
|
||
|
|
-size_t rpmfiArchiveRead(rpmfi fi, void * buf, size_t size);
|
||
|
|
+ssize_t rpmfiArchiveRead(rpmfi fi, void * buf, size_t size);
|
||
|
|
|
||
|
|
/** \ingroup payload
|
||
|
|
* Has current file content stored in the archive
|
||
|
|
diff --git a/lib/rpmfi.c b/lib/rpmfi.c
|
||
|
|
index c314a8b29..af428468c 100644
|
||
|
|
--- a/lib/rpmfi.c
|
||
|
|
+++ b/lib/rpmfi.c
|
||
|
|
@@ -2261,7 +2261,7 @@ int rpmfiArchiveHasContent(rpmfi fi)
|
||
|
|
return res;
|
||
|
|
}
|
||
|
|
|
||
|
|
-size_t rpmfiArchiveRead(rpmfi fi, void * buf, size_t size)
|
||
|
|
+ssize_t rpmfiArchiveRead(rpmfi fi, void * buf, size_t size)
|
||
|
|
{
|
||
|
|
if (fi == NULL || fi->archive == NULL)
|
||
|
|
return -1;
|
||
|
|
--
|
||
|
|
2.27.0
|
||
|
|
|