From e60acaf57f6ef282ee2367a63d61a6e979747e94 Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Fri, 18 Apr 2008 10:23:40 +0000 Subject: [PATCH] - backport patch from upstream to avoid segfault when data phase is skipped for certain devices (#435413) - initial build --- gphoto2-data-phase.patch | 29 +++++++++++++++++++++++++++++ libgphoto2.spec | 9 ++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 gphoto2-data-phase.patch diff --git a/gphoto2-data-phase.patch b/gphoto2-data-phase.patch new file mode 100644 index 0000000..d68e834 --- /dev/null +++ b/gphoto2-data-phase.patch @@ -0,0 +1,29 @@ +diff -up gphoto2-2.4.0/libgphoto2-2.4.0/camlibs/ptp2/ptp.c.data-phase gphoto2-2.4.0/libgphoto2-2.4.0/camlibs/ptp2/ptp.c +--- libgphoto2-2.4.0/camlibs/ptp2/ptp.c.data-phase 2007-07-27 02:35:37.000000000 +0200 ++++ libgphoto2-2.4.0/camlibs/ptp2/ptp.c 2008-04-17 06:19:34.000000000 +0200 +@@ -2775,13 +2775,23 @@ ptp_mtp_getobjectreferences (PTPParams* + PTPContainer ptp; + uint16_t ret; + unsigned char* dpv=NULL; ++ unsigned int dpvlen = 0; + + PTP_CNT_INIT(ptp); + ptp.Code=PTP_OC_MTP_GetObjectReferences; + ptp.Param1=handle; + ptp.Nparam=1; +- ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, NULL); +- if (ret == PTP_RC_OK) *arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray); ++ ret=ptp_transaction(params, &ptp, PTP_DP_GETDATA, 0, &dpv, &dpvlen); ++ if (ret == PTP_RC_OK) { ++ /* Sandisk Sansa skips the DATA phase, but returns OK as response. ++ * this will give us a NULL here. Handle it. -Marcus */ ++ if ((dpv == NULL) || (dpvlen == 0)) { ++ *arraylen = 0; ++ *ohArray = NULL; ++ } else { ++ *arraylen = ptp_unpack_uint32_t_array(params, dpv, 0, ohArray); ++ } ++ } + free(dpv); + return ret; + } diff --git a/libgphoto2.spec b/libgphoto2.spec index 3ff9799..0683c86 100644 --- a/libgphoto2.spec +++ b/libgphoto2.spec @@ -1,7 +1,7 @@ Summary: Library for accessing digital cameras Name: libgphoto2 Version: 2.4.0 -Release: 0.2%{?dist} +Release: 1%{?dist} # GPLV2+ for the main lib (due to exif.c) and most plugins, some plugins GPLv2 License: GPLv2+ and GPLv2 Group: Development/Libraries @@ -11,6 +11,7 @@ Patch1: gphoto2-pkgcfg.patch Patch2: gphoto2-storage.patch Patch3: gphoto2-ixany.patch Patch4: gphoto2-norpath.patch +Patch5: gphoto2-data-phase.patch Url: http://www.gphoto.org/ Requires: lockdev BuildRequires: libusb-devel >= 0.1.5 @@ -47,6 +48,7 @@ use libgphoto2. %patch2 -p1 -b .storage %patch3 -p1 -b .ixany %patch4 -p1 -b .norpath +%patch5 -p1 -b .data-phase cat > gphoto2.pc.in << EOF prefix=@prefix@ @@ -137,6 +139,11 @@ rm -rf "${RPM_BUILD_ROOT}" %{_mandir}/man3/* %changelog +* Fri Apr 18 2008 Jindrich Novy 2.4.0-1 +- backport patch from upstream to avoid segfault when + data phase is skipped for certain devices (#435413) +- initial build + * Mon Apr 14 2008 Jindrich Novy 2.4.0-0.2 - review fixes, thanks to Hans de Goede: (#437285) - remove unused macro