diff --git a/userspace/libswitchhw/i2c_sfp.c b/userspace/libswitchhw/i2c_sfp.c
index 7656c386ba7ed1a71dd971f479e198e01ae8c52a..d26e7ea22a80bbd831e52acd5c936369c9f3d2f7 100644
--- a/userspace/libswitchhw/i2c_sfp.c
+++ b/userspace/libswitchhw/i2c_sfp.c
@@ -589,7 +589,7 @@ int shw_sfp_read_db(char *filename)
 		lua_pop(L, 1);
 
 		sfp = malloc(sizeof(struct shw_sfp_caldata));
-		strcpy(sfp->part_num, sfp_pn);
+		strncpy(sfp->part_num, sfp_pn, sizeof(sfp->part_num));
 		if (!sfp_vs || strcmp(sfp_vs, "") == 0) {
 			sfp->vendor_serial[0] = 0;
 			sfp->flags |= SFP_FLAG_CLASS_DATA;
@@ -639,9 +639,9 @@ struct shw_sfp_caldata *shw_sfp_get_cal_data(int num)
 	/* In the first pass, look for serial number */
 	while (t) {
 //		printf("search1 %s %s\n", t->part_num, t->vendor_serial);
-		if (strcmp(pn, t->part_num) == 0 && strcmp(t->vendor_serial, "") == 0)
+		if (strncmp(pn, t->part_num, 16) == 0 && strncmp(t->vendor_serial, "", 16) == 0)
 			other = t;
-		else if (strcmp(pn, t->part_num) == 0 && strcmp(vs, t->vendor_serial) == 0)
+		else if (strncmp(pn, t->part_num, 16) == 0 && strncmp(vs, t->vendor_serial, 16) == 0)
 			return t;
 		t = t->next;
 	}