Modify

Opened 11 years ago

Closed 11 years ago

Last modified 4 years ago

#1261 closed defect (fixed)

Bugs in libgphoto

Reported by: alesan@… Owned by: developers
Priority: high Milestone: Barrier Breaker 14.07
Component: packages Version:
Keywords: Cc:

Description

There is a nasty bug in libgphoto (probably due to bad compatibility with libiconv) that leads to a segmentation fault when using libgphoto with the ptp protocol. The following patch solves the problem:

Index: camlibs/ptp2/ptp-pack.c
===================================================================
--- camlibs/ptp2/ptp-pack.c (revision 9934)
+++ camlibs/ptp2/ptp-pack.c (revision 9935)
@@ -116,8 +116,17 @@

nconv = iconv (params->cd_ucs2_to_locale, &stringp, &convlen, &locp, &convmax);
/* FIXME: handle size errors */
loclstr[PTP_MAXSTRLEN*3] = '\0';

  • if (nconv == (size_t) -1)
  • return NULL;

+ if (nconv == (size_t) -1) {
+ int i;
+ /* try the old way, in case iconv is broken */
+ for (i=0;i<loclen;i++) {
+ if (string[i]>127)
+ loclstr[i] = '?';
+ else
+ loclstr[i] = string[i];
+ }
+ string[loclen] = 0;
+ }

return strdup(loclstr);

}
return NULL;

Attachments (0)

Change History (3)

comment:1 Changed 11 years ago by alesan@…

ok I forgot to open the code block:

Index: camlibs/ptp2/ptp-pack.c
===================================================================
--- camlibs/ptp2/ptp-pack.c     (revision 9934)
+++ camlibs/ptp2/ptp-pack.c     (revision 9935)
@@ -116,8 +116,17 @@
                nconv = iconv (params->cd_ucs2_to_locale, &stringp, &convlen, &locp, &convmax);
                /* FIXME: handle size errors */
                loclstr[PTP_MAXSTRLEN*3] = '\0';
-               if (nconv == (size_t) -1)
-                       return NULL;
+               if (nconv == (size_t) -1) {
+                       int i;
+                       /* try the old way, in case iconv is broken */
+                       for (i=0;i<loclen;i++) {
+                               if (string[i]>127)
+                                       loclstr[i] = '?';
+                               else
+                                       loclstr[i] = string[i];
+                       }
+                       string[loclen] = 0;
+               }
                return strdup(loclstr);
        }
        return NULL;

comment:2 Changed 11 years ago by florian

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in [6409], thanks !

comment:3 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.