diff --git a/camlibs/ptp2/ChangeLog b/camlibs/ptp2/ChangeLog index 27b8f7a26..e590e50eb 100644 --- a/camlibs/ptp2/ChangeLog +++ b/camlibs/ptp2/ChangeLog @@ -3,6 +3,8 @@ * library.c: Added HP Photosmart E317 * library.c: Relaxed Association checks for directories. The E317 sees AssocType 0x0 (undefined) for DCIM/ et.al. + + Avoid buffer overflows on too long filenames. 2006-01-17 Marcus Meissner diff --git a/camlibs/ptp2/library.c b/camlibs/ptp2/library.c index e5bcd1385..0b9e22c0b 100644 --- a/camlibs/ptp2/library.c +++ b/camlibs/ptp2/library.c @@ -3644,7 +3644,11 @@ get_info_func (CameraFilesystem *fs, const char *folder, const char *filename, oi=&camera->pl->params.objectinfo[object_id]; info->file.fields = GP_FILE_INFO_SIZE|GP_FILE_INFO_TYPE|GP_FILE_INFO_MTIME; - if (oi->Filename) { + + /* Avoid buffer overflows on long filenames, just don't copy it + * if it is too long. + */ + if (oi->Filename && (strlen(oi->Filename)+1 < sizeof(info->file.name))) { strcpy(info->file.name, oi->Filename); info->file.fields |= GP_FILE_INFO_NAME; }