epson: don't leak memory if realloc() fails
This commit is contained in:
parent
6ef393bf23
commit
b96345062f
@ -1,4 +1,4 @@
|
|||||||
From fc5281af7dad490171933ca706a7c34c891269b5 Mon Sep 17 00:00:00 2001
|
From 886208261b5b91b4a64efd8a203873ab85a07a2e Mon Sep 17 00:00:00 2001
|
||||||
From: Nils Philippsen <nils@redhat.com>
|
From: Nils Philippsen <nils@redhat.com>
|
||||||
Date: Thu, 7 Nov 2013 12:48:23 +0100
|
Date: Thu, 7 Nov 2013 12:48:23 +0100
|
||||||
Subject: [PATCH] patch: static-code-check
|
Subject: [PATCH] patch: static-code-check
|
||||||
@ -7,6 +7,14 @@ Fix problems found during static code check (Coverity).
|
|||||||
|
|
||||||
Squashed commit of the following:
|
Squashed commit of the following:
|
||||||
|
|
||||||
|
commit e24cea3bceb5dad2042dcd95f582d6c8acf4c9ee
|
||||||
|
Author: Nils Philippsen <nils@redhat.com>
|
||||||
|
Date: Thu Nov 7 14:29:28 2013 +0100
|
||||||
|
|
||||||
|
epson: don't leak memory if realloc() fails
|
||||||
|
|
||||||
|
(cherry picked from commit d835d9d565118d52c2339c2e79890f57d0616077)
|
||||||
|
|
||||||
commit b0c14b86210c7615ea4d90723722a7430b175ae2
|
commit b0c14b86210c7615ea4d90723722a7430b175ae2
|
||||||
Author: Nils Philippsen <nils@redhat.com>
|
Author: Nils Philippsen <nils@redhat.com>
|
||||||
Date: Wed Nov 6 11:05:58 2013 +0100
|
Date: Wed Nov 6 11:05:58 2013 +0100
|
||||||
@ -119,7 +127,7 @@ Date: Tue Nov 5 11:39:56 2013 +0100
|
|||||||
|
|
||||||
(cherry picked from commit 56104b5329076d45caf2e04a2271f40a2699f71f)
|
(cherry picked from commit 56104b5329076d45caf2e04a2271f40a2699f71f)
|
||||||
---
|
---
|
||||||
backend/epson.c | 34 +++++++++++++++++++----------
|
backend/epson.c | 36 +++++++++++++++++++++----------
|
||||||
backend/genesys.c | 9 +++++---
|
backend/genesys.c | 9 +++++---
|
||||||
backend/genesys_devices.c | 3 +++
|
backend/genesys_devices.c | 3 +++
|
||||||
backend/genesys_gl124.c | 21 ++++++++++++++++--
|
backend/genesys_gl124.c | 21 ++++++++++++++++--
|
||||||
@ -132,10 +140,10 @@ Date: Tue Nov 5 11:39:56 2013 +0100
|
|||||||
backend/rts8891.c | 16 ++++++--------
|
backend/rts8891.c | 16 ++++++--------
|
||||||
sanei/sanei_usb.c | 2 --
|
sanei/sanei_usb.c | 2 --
|
||||||
tools/sane-find-scanner.c | 2 --
|
tools/sane-find-scanner.c | 2 --
|
||||||
13 files changed, 139 insertions(+), 69 deletions(-)
|
13 files changed, 141 insertions(+), 69 deletions(-)
|
||||||
|
|
||||||
diff --git a/backend/epson.c b/backend/epson.c
|
diff --git a/backend/epson.c b/backend/epson.c
|
||||||
index 2cae65a..08f1401 100644
|
index 2cae65a..3b063b9 100644
|
||||||
--- a/backend/epson.c
|
--- a/backend/epson.c
|
||||||
+++ b/backend/epson.c
|
+++ b/backend/epson.c
|
||||||
@@ -818,6 +818,12 @@ typedef struct
|
@@ -818,6 +818,12 @@ typedef struct
|
||||||
@ -169,7 +177,7 @@ index 2cae65a..08f1401 100644
|
|||||||
command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
|
command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
|
||||||
SANE_Status * status)
|
SANE_Status * status)
|
||||||
{
|
{
|
||||||
+ EpsonHdrUnion hdrunion;
|
+ EpsonHdrUnion hdrunion, hdrunion_bak;
|
||||||
EpsonHdr head;
|
EpsonHdr head;
|
||||||
u_char *buf;
|
u_char *buf;
|
||||||
int count;
|
int count;
|
||||||
@ -206,7 +214,7 @@ index 2cae65a..08f1401 100644
|
|||||||
|
|
||||||
DBG (4, "code %02x\n", (int) head->code);
|
DBG (4, "code %02x\n", (int) head->code);
|
||||||
|
|
||||||
@@ -1921,25 +1930,28 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
|
@@ -1921,25 +1930,30 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SANE_STATUS_GOOD != *status)
|
if (SANE_STATUS_GOOD != *status)
|
||||||
@ -219,9 +227,11 @@ index 2cae65a..08f1401 100644
|
|||||||
DBG (4, "count %d\n", count);
|
DBG (4, "count %d\n", count);
|
||||||
|
|
||||||
- if (NULL == (head = realloc (head, sizeof (EpsonHdrRec) + count)))
|
- if (NULL == (head = realloc (head, sizeof (EpsonHdrRec) + count)))
|
||||||
|
+ hdrunion_bak = hdrunion;
|
||||||
+ if (NULL == (hdrunion = realloc (hdrunion,
|
+ if (NULL == (hdrunion = realloc (hdrunion,
|
||||||
+ sizeof (EpsonHdrUnionRec) + count)))
|
+ sizeof (EpsonHdrUnionRec) + count)))
|
||||||
{
|
{
|
||||||
|
+ free(hdrunion_bak);
|
||||||
DBG (1, "out of memory (line %d)\n", __LINE__);
|
DBG (1, "out of memory (line %d)\n", __LINE__);
|
||||||
*status = SANE_STATUS_NO_MEM;
|
*status = SANE_STATUS_NO_MEM;
|
||||||
- return (EpsonHdr) 0;
|
- return (EpsonHdr) 0;
|
||||||
@ -239,7 +249,7 @@ index 2cae65a..08f1401 100644
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1953,7 +1965,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
|
@@ -1953,7 +1967,7 @@ command (Epson_Scanner * s, u_char * cmd, size_t cmd_size,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
Summary: Scanner access software
|
Summary: Scanner access software
|
||||||
Name: sane-backends
|
Name: sane-backends
|
||||||
Version: 1.0.24
|
Version: 1.0.24
|
||||||
Release: 5%{?dist}
|
Release: 6%{?dist}
|
||||||
# lib/ is LGPLv2+, backends are GPLv2+ with exceptions
|
# lib/ is LGPLv2+, backends are GPLv2+ with exceptions
|
||||||
# Tools are GPLv2+, docs are public domain
|
# Tools are GPLv2+, docs are public domain
|
||||||
# see LICENSE for details
|
# see LICENSE for details
|
||||||
@ -71,6 +71,7 @@ Patch5: sane-backends-1.0.24-pixma_bjnp-crash.patch
|
|||||||
# Upstream commit 602d6ecdfe5f3146867799fabf3ac87582c26461
|
# Upstream commit 602d6ecdfe5f3146867799fabf3ac87582c26461
|
||||||
# Upstream commit 5d7f7ffefb22e7e64789e97af0356b7859d61814
|
# Upstream commit 5d7f7ffefb22e7e64789e97af0356b7859d61814
|
||||||
# Upstream commit dc76e7cce464f04e46aab2bb0c269b4742161c59
|
# Upstream commit dc76e7cce464f04e46aab2bb0c269b4742161c59
|
||||||
|
# Upstream commit d835d9d565118d52c2339c2e79890f57d0616077
|
||||||
Patch6: sane-backends-1.0.24-static-code-check.patch
|
Patch6: sane-backends-1.0.24-static-code-check.patch
|
||||||
|
|
||||||
URL: http://www.sane-project.org
|
URL: http://www.sane-project.org
|
||||||
@ -308,6 +309,9 @@ udevadm hwdb --update >/dev/null 2>&1 || :
|
|||||||
%{_libdir}/sane/*gphoto2.so*
|
%{_libdir}/sane/*gphoto2.so*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Nov 07 2013 Nils Philippsen <nils@redhat.com> - 1.0.24-6
|
||||||
|
- epson: don't leak memory if realloc() fails
|
||||||
|
|
||||||
* Thu Nov 07 2013 Nils Philippsen <nils@redhat.com> - 1.0.24-5
|
* Thu Nov 07 2013 Nils Philippsen <nils@redhat.com> - 1.0.24-5
|
||||||
- fix issues found during static code check
|
- fix issues found during static code check
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user