Skip to content

Commit

Permalink
Old kernels don't have strscpy, so use strlcpy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Richardson committed Jul 1, 2020
1 parent 1dcebc1 commit 2f818bb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions availink/avl62x1/avl62x1_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ static int __init mod_init(void) {
}

if(strlen(sel_fw) == 0) {
strscpy(sel_fw, AVL62X1_FIRMWARE, sizeof(sel_fw));
strlcpy(sel_fw, AVL62X1_FIRMWARE, sizeof(sel_fw));
}

return 0;
Expand Down Expand Up @@ -1812,8 +1812,8 @@ MODULE_PARM_DESC(bs_min_sr, " minimum symbol rate (Hz) for blindscan mode [10000
static int fw_path_set(const char *val, const struct kernel_param *kp)
{
char *clean_val = strim((char *)val);
strscpy(sel_fw, clean_val, sizeof(sel_fw));
strscpy(fw_path, clean_val, sizeof(fw_path));
strlcpy(sel_fw, clean_val, sizeof(sel_fw));
strlcpy(fw_path, clean_val, sizeof(fw_path));

if (global_priv != NULL)
{
Expand Down
34 changes: 17 additions & 17 deletions availink/avl68x2/avl68x2_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,19 +628,19 @@ static int avl68x2_get_firmware(struct dvb_frontend *fe, int force_fw)
{
case SYS_DVBS:
case SYS_DVBS2:
strscpy(fw_path, sel_dvbsx_fw, sizeof(fw_path));
strlcpy(fw_path, sel_dvbsx_fw, sizeof(fw_path));
break;
case SYS_ISDBT:
strscpy(fw_path, sel_isdbt_fw, sizeof(fw_path));
strlcpy(fw_path, sel_isdbt_fw, sizeof(fw_path));
break;
case SYS_DVBC_ANNEX_A: //"DVB-C"
case SYS_DVBC_ANNEX_B: //J.83-B
strscpy(fw_path, sel_dvbc_fw, sizeof(fw_path));
strlcpy(fw_path, sel_dvbc_fw, sizeof(fw_path));
break;
case SYS_DVBT:
case SYS_DVBT2:
default:
strscpy(fw_path, sel_dvbtx_fw, sizeof(fw_path));
strlcpy(fw_path, sel_dvbtx_fw, sizeof(fw_path));
}

fw_status = request_firmware(&priv->fw, fw_path, priv->i2c->dev.parent);
Expand Down Expand Up @@ -2029,28 +2029,28 @@ struct dvb_frontend *avl68x2_attach(struct avl68x2_config *config,
//C, I, S, T
memcpy(&avl68x2_ops.delsys,
delsys_b, sizeof(delsys_b));
strscpy(feat_str,"DVB-C/Sx/Tx, J.83B, and ISDB-T",sizeof(feat_str));
strlcpy(feat_str,"DVB-C/Sx/Tx, J.83B, and ISDB-T",sizeof(feat_str));
part_num = 6882;
break;
case 0xd:
//C, I, S
memcpy(&avl68x2_ops.delsys,
delsys_d, sizeof(delsys_d));
strscpy(feat_str,"DVB-C/Sx, J.83B, and ISDB-T",sizeof(feat_str));
strlcpy(feat_str,"DVB-C/Sx, J.83B, and ISDB-T",sizeof(feat_str));
part_num = 6812;
break;
case 0xe:
//C, T
memcpy(&avl68x2_ops.delsys,
delsys_e, sizeof(delsys_e));
strscpy(feat_str,"DVB-C/Tx and J.83B",sizeof(feat_str));
strlcpy(feat_str,"DVB-C/Tx and J.83B",sizeof(feat_str));
part_num = 6762;
break;
case 0xf:
//C, S, T
memcpy(&avl68x2_ops.delsys,
delsys_f, sizeof(delsys_f));
strscpy(feat_str,"DVB-C/Sx/Tx and J.83B",sizeof(feat_str));
strlcpy(feat_str,"DVB-C/Sx/Tx and J.83B",sizeof(feat_str));
part_num = 6862;
break;
default:
Expand Down Expand Up @@ -2117,16 +2117,16 @@ static int __init mod_init(void) {
}

if(strlen(sel_dvbsx_fw) == 0) {
strscpy(sel_dvbsx_fw, AVL68X2_DVBSX_FW, sizeof(sel_dvbsx_fw));
strlcpy(sel_dvbsx_fw, AVL68X2_DVBSX_FW, sizeof(sel_dvbsx_fw));
}
if(strlen(sel_dvbtx_fw) == 0) {
strscpy(sel_dvbtx_fw, AVL68X2_DVBTX_FW, sizeof(sel_dvbtx_fw));
strlcpy(sel_dvbtx_fw, AVL68X2_DVBTX_FW, sizeof(sel_dvbtx_fw));
}
if(strlen(sel_dvbc_fw) == 0) {
strscpy(sel_dvbc_fw, AVL68X2_DVBC_FW, sizeof(sel_dvbc_fw));
strlcpy(sel_dvbc_fw, AVL68X2_DVBC_FW, sizeof(sel_dvbc_fw));
}
if(strlen(sel_isdbt_fw) == 0) {
strscpy(sel_isdbt_fw, AVL68X2_ISDBT_FW, sizeof(sel_isdbt_fw));
strlcpy(sel_isdbt_fw, AVL68X2_ISDBT_FW, sizeof(sel_isdbt_fw));
}

return 0;
Expand Down Expand Up @@ -2276,7 +2276,7 @@ static int fw_paths_set(const char *val, const struct kernel_param *kp)
len = get_fw_path(val,"C=",&b);
if(len != 0) {
memset(sel_dvbc_fw,0,sizeof(sel_dvbc_fw));
strscpy(sel_dvbc_fw,
strlcpy(sel_dvbc_fw,
&b[2],
min(len - 2, sizeof(sel_dvbc_fw)));
p_info("set C=%s",sel_dvbc_fw);
Expand All @@ -2287,7 +2287,7 @@ static int fw_paths_set(const char *val, const struct kernel_param *kp)
len = get_fw_path(val,"I=",&b);
if(len != 0) {
memset(sel_isdbt_fw,0,sizeof(sel_isdbt_fw));
strscpy(sel_isdbt_fw,
strlcpy(sel_isdbt_fw,
&b[2],
min(len - 2, sizeof(sel_isdbt_fw)));
p_info("set I=%s",sel_isdbt_fw);
Expand All @@ -2298,7 +2298,7 @@ static int fw_paths_set(const char *val, const struct kernel_param *kp)
len = get_fw_path(val,"S=",&b);
if(len != 0) {
memset(sel_dvbsx_fw,0,sizeof(sel_dvbsx_fw));
strscpy(sel_dvbsx_fw,
strlcpy(sel_dvbsx_fw,
&b[2],
min(len - 2, sizeof(sel_dvbsx_fw)));
p_info("set S=%s",sel_dvbsx_fw);
Expand All @@ -2309,14 +2309,14 @@ static int fw_paths_set(const char *val, const struct kernel_param *kp)
len = get_fw_path(val,"T=",&b);
if(len != 0) {
memset(sel_dvbtx_fw,0,sizeof(sel_dvbtx_fw));
strscpy(sel_dvbtx_fw,
strlcpy(sel_dvbtx_fw,
&b[2],
min(len - 2, sizeof(sel_dvbtx_fw)));
p_info("set T=%s",sel_dvbtx_fw);
mode = AVL_DVBTX;
delsys = SYS_DVBT2;
}
strscpy(fw_paths,val,sizeof(fw_paths));
strlcpy(fw_paths,val,sizeof(fw_paths));

if(global_priv != NULL) {
if(avl68x2_get_firmware(&global_priv->frontend,delsys))
Expand Down

0 comments on commit 2f818bb

Please sign in to comment.