summaryrefslogtreecommitdiff
path: root/backend/plustek-usb.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2020-02-02 17:14:32 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2020-02-02 17:14:32 +0100
commit5dadc28ea784db1ba1f56c2ea8618d2db67af1c8 (patch)
tree808b2499b54563b3290f34d70d159b1024310873 /backend/plustek-usb.c
parent5bb4cf12855ec0151de15d6c5a2354ff08766957 (diff)
parent3dade5db2a37543f19f0967901d8d80a52a1e459 (diff)
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'backend/plustek-usb.c')
-rw-r--r--backend/plustek-usb.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/backend/plustek-usb.c b/backend/plustek-usb.c
index 5c6fbeb..107bf9e 100644
--- a/backend/plustek-usb.c
+++ b/backend/plustek-usb.c
@@ -193,6 +193,7 @@ usb_initDev( Plustek_Device *dev, int idx, int handle, int vendor )
int i;
ScanParam sParam;
u_short tmp = 0;
+ int ret = 0;
DBG( _DBG_INFO, "usb_initDev(%d,0x%04x,%i)\n",
idx, vendor, dev->initialized );
@@ -305,11 +306,16 @@ usb_initDev( Plustek_Device *dev, int idx, int handle, int vendor )
}
ptr = getenv ("HOME");
- if( NULL == ptr ) {
- sprintf( tmp_str2, "/tmp/%s", tmp_str1 );
- } else {
- sprintf( tmp_str2, "%s/.sane/%s", ptr, tmp_str1 );
+ ret = ( NULL == ptr )?
+ snprintf( tmp_str2, sizeof(tmp_str2), "/tmp/%s", tmp_str1 ):
+ snprintf( tmp_str2, sizeof(tmp_str2), "%s/.sane/%s", ptr, tmp_str1 );
+
+ if ((ret < 0) || (ret > (int)sizeof(tmp_str2))) {
+ DBG( _DBG_WARNING,
+ "Failed to generate calibration file path. Default substituted.\n" );
+ snprintf(tmp_str2, sizeof(tmp_str2), "/tmp/plustek-default");
}
+
dev->calFile = strdup( tmp_str2 );
DBG( _DBG_INFO, "Calibration file-names set to:\n" );
DBG( _DBG_INFO, ">%s-coarse.cal<\n", dev->calFile );