summaryrefslogtreecommitdiff
path: root/backend/ieee1284.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2010-04-09 22:45:27 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2010-04-09 22:45:27 +0000
commit39ff2fe72b9fc06ae7acc909584f87874f3a71b8 (patch)
tree15c098dbbce2d129a36a273dd777a179db37b8d3 /backend/ieee1284.c
parentaaf19ab07e5ba1f270e4ebbc321a1a0b76a4d25f (diff)
downloadcups-39ff2fe72b9fc06ae7acc909584f87874f3a71b8.tar.gz
Merge changes from CUPS 1.5svn-r9098.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@2056 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'backend/ieee1284.c')
-rw-r--r--backend/ieee1284.c41
1 files changed, 32 insertions, 9 deletions
diff --git a/backend/ieee1284.c b/backend/ieee1284.c
index b84776d09..bf994891c 100644
--- a/backend/ieee1284.c
+++ b/backend/ieee1284.c
@@ -186,18 +186,34 @@ backendGetDeviceID(
/*
* The length field counts the number of bytes in the string
- * including the length field itself (2 bytes).
+ * including the length field itself (2 bytes). The minimum
+ * length for a valid/usable device ID is 14 bytes:
+ *
+ * <LENGTH> MFG: <MFG> ;MDL: <MDL> ;
+ * 2 + 4 + 1 + 5 + 1 + 1
*/
- length -= 2;
+ if (length < 14)
+ {
+ /*
+ * Can't use this device ID, so don't try to copy it...
+ */
- /*
- * Copy the device ID text to the beginning of the buffer and
- * nul-terminate.
- */
+ device_id[0] = '\0';
+ got_id = 0;
+ }
+ else
+ {
+ /*
+ * Copy the device ID text to the beginning of the buffer and
+ * nul-terminate.
+ */
- memmove(device_id, device_id + 2, length);
- device_id[length] = '\0';
+ length -= 2;
+
+ memmove(device_id, device_id + 2, length);
+ device_id[length] = '\0';
+ }
}
# ifdef DEBUG
else
@@ -294,6 +310,9 @@ backendGetDeviceID(
mfg = temp;
}
+ if (!mdl)
+ mdl = "";
+
if (!strncasecmp(mdl, mfg, strlen(mfg)))
{
mdl += strlen(mfg);
@@ -385,7 +404,11 @@ backendGetMakeModel(
char temp[1024]; /* Temporary make and model */
- snprintf(temp, sizeof(temp), "%s %s", mfg, mdl);
+ if (mfg)
+ snprintf(temp, sizeof(temp), "%s %s", mfg, mdl);
+ else
+ snprintf(temp, sizeof(temp), "%s", mdl);
+
_ppdNormalizeMakeAndModel(temp, make_model, make_model_size);
}
}