summaryrefslogtreecommitdiff
path: root/libgphoto2_port/libgphoto2_port
diff options
context:
space:
mode:
authorMarcus Meissner <marcus@linux-n4oc.site>2016-09-25 17:53:16 +0200
committerMarcus Meissner <marcus@linux-n4oc.site>2016-09-25 17:53:16 +0200
commitf5940df96ff0be12482b0f91bbb9853fcce1eeb7 (patch)
tree9ecc953883399c93306b97d9fa2e5e29f4de0607 /libgphoto2_port/libgphoto2_port
parent4950324701f44bbc96c396e3fcdb19de261a2a87 (diff)
downloadlibgphoto2-f5940df96ff0be12482b0f91bbb9853fcce1eeb7.tar.gz
report error when setting a too long port, do not silently truncate
Diffstat (limited to 'libgphoto2_port/libgphoto2_port')
-rw-r--r--libgphoto2_port/libgphoto2_port/gphoto2-port.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/libgphoto2_port/libgphoto2_port/gphoto2-port.c b/libgphoto2_port/libgphoto2_port/gphoto2-port.c
index 1842970b9..6445b96c9 100644
--- a/libgphoto2_port/libgphoto2_port/gphoto2-port.c
+++ b/libgphoto2_port/libgphoto2_port/gphoto2-port.c
@@ -208,6 +208,10 @@ gp_port_set_info (GPPort *port, GPPortInfo info)
gp_port_set_timeout (port, 500);
break;
case GP_PORT_USB:
+ if (sizeof (port->settings.usb.port) <= strlen(info->path)) {
+ GP_LOG_E ("Path is too long for static buffer '%s'.", info->path);
+ return GP_ERROR_LIBRARY;
+ }
strncpy (port->settings.usb.port, info->path,
sizeof (port->settings.usb.port));
port->settings.usb.inep = -1;