do not return names in info_func if longer than the actual buffersize.

git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@8512 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
Marcus Meissner
2006-01-21 21:56:50 +00:00
parent 0a9c719dea
commit 4e8f434d7c
2 changed files with 7 additions and 1 deletions

View File

@@ -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 <marcus@jet.franken.de>

View File

@@ -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;
}