diff mbox series

[v1,1/1] package/rtl8821au: add patch fixing sprintf error

Message ID 20200801203749.424827-1-christian@paral.in
State Superseded
Headers show
Series [v1,1/1] package/rtl8821au: add patch fixing sprintf error | expand

Commit Message

Christian Stewart Aug. 1, 2020, 8:37 p.m. UTC
Fixes compile errors against certain kernels.

Signed-off-by: Christian Stewart <christian@paral.in>
---
 ...f-for-extending-string-which-causes-.patch | 336 ++++++++++++++++++
 1 file changed, 336 insertions(+)
 create mode 100644 package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch

Comments

Thomas Petazzoni Aug. 1, 2020, 9:17 p.m. UTC | #1
On Sat,  1 Aug 2020 13:37:49 -0700
Christian Stewart <christian@paral.in> wrote:

> Fixes compile errors against certain kernels.
> 
> Signed-off-by: Christian Stewart <christian@paral.in>
> ---
>  ...f-for-extending-string-which-causes-.patch | 336 ++++++++++++++++++
>  1 file changed, 336 insertions(+)
>  create mode 100644 package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> 
> diff --git a/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> new file mode 100644
> index 0000000000..6753eefdd9
> --- /dev/null
> +++ b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> @@ -0,0 +1,336 @@
> +From cc3262a32ce326d89d597bb8557ce0da05240e98 Mon Sep 17 00:00:00 2001
> +From: Coleman <omegacoleman@gmail.com>
> +Date: Fri, 17 Jul 2020 08:53:00 +0800
> +Subject: [PATCH 3/3] Fix using sprintf for extending string, which causes

The 3/3 shouldn't be there, it causes a check-package warning.

> + undefined behavior. (#334)
> +

We need your Signed-off-by here.

Thanks!

Thomas
Peter Seiderer Aug. 1, 2020, 9:34 p.m. UTC | #2
Hello Christian,


thanks for the patch, but...

On Sat,  1 Aug 2020 13:37:49 -0700, Christian Stewart <christian@paral.in> wrote:

> Fixes compile errors against certain kernels.
>
> Signed-off-by: Christian Stewart <christian@paral.in>
> ---
>  ...f-for-extending-string-which-causes-.patch | 336 ++++++++++++++++++
>  1 file changed, 336 insertions(+)
>  create mode 100644 package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
>
> diff --git a/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> new file mode 100644
> index 0000000000..6753eefdd9
> --- /dev/null
> +++ b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> @@ -0,0 +1,336 @@
> +From cc3262a32ce326d89d597bb8557ce0da05240e98 Mon Sep 17 00:00:00 2001
> +From: Coleman <omegacoleman@gmail.com>
> +Date: Fri, 17 Jul 2020 08:53:00 +0800
> +Subject: [PATCH 3/3] Fix using sprintf for extending string, which causes
> + undefined behavior. (#334)
> +

The patch should have an note about the upstream source (see [1]), I suspect you
toke the patch from [2]?

The patch itself should have your 'Signed-off-by', see [3]...

With this fixed you can add my 'Reviewed-by'...

Or maybe its worth to try some other 'upstream' sources, e.g. as
openSUSE [4] does (mentioning previous [5] and [6]), or the first
google search result [7] (did not find the time to dig into the
different repositories to find out which one is the best)...

Regards,
Peter


[1] https://buildroot.org/downloads/manual/manual.html#_integrating_patches_found_on_the_web
[2] https://github.com/abperiasamy/rtl8812AU_8821AU_linux/commit/be57045a0933d64e958878696883e9cf998e1bf3.patch
[3] https://buildroot.org/downloads/manual/manual.html#_format_and_licensing_of_the_package_patches
[4] https://github.com/gordboy/rtl8812au
[5] https://github.com/diederikdehaas/rtl8812AU
[6] https://github.com/maurossi/rtl8812au/
[7] https://github.com/gnab/rtl8812au


> +---
> + core/rtw_mp.c              |   2 +-
> + os_dep/linux/ioctl_linux.c | 108 ++++++++++++++++++-------------------
> + 2 files changed, 55 insertions(+), 55 deletions(-)
> +
> +diff --git a/core/rtw_mp.c b/core/rtw_mp.c
> +index c2e400d..989bb3e 100644
> +--- a/core/rtw_mp.c
> ++++ b/core/rtw_mp.c
> +@@ -1871,7 +1871,7 @@ u32 mp_query_psd(PADAPTER pAdapter, u8 *data)
> + 		} else {
> + 			psd_data = rtw_GetPSDData(pAdapter, i);
> + 		}
> +-		sprintf(data, "%s%x ", data, psd_data);
> ++		sprintf(data + strlen(data), "%x ", psd_data);
> + 		i++;
> + 	}
> +
> +diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c
> +index c74a153..9543fa3 100644
> +--- a/os_dep/linux/ioctl_linux.c
> ++++ b/os_dep/linux/ioctl_linux.c
> +@@ -9080,19 +9080,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
> + //			DBG_871X("0x%02x\t", i);
> +-			sprintf(extra, "%s0x%02x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%02x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", data[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra, "%s\t", extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", data[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra,"%s\n",extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> + 	} else if (strcmp(tmp[0], "realmap") == 0) {
> +@@ -9107,19 +9107,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
> + //			DBG_871X("0x%02x\t", i);
> +-			sprintf(extra, "%s0x%02x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%02x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", data[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra, "%s\t", extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", data[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra,"%s\n",extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> + 	} else if (strcmp(tmp[0], "rmap") == 0) {
> +@@ -9158,7 +9158,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		*extra = 0;
> + 		for (i=0; i<cnts; i++) {
> + //			DBG_871X("0x%02x ", data[i]);
> +-			sprintf(extra, "%s0x%02X ", extra, data[i]);
> ++			sprintf(extra + strlen(extra), "0x%02X ", data[i]);
> + 		}
> + //		DBG_871X("}\n");
> + 	} else if (strcmp(tmp[0], "realraw") == 0) {
> +@@ -9174,17 +9174,17 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n0x00\t");
> + 		for (i=0; i< mapLen; i++) {
> + 			//			DBG_871X("%02X", rawdata[i]);
> +-			sprintf(extra, "%s%02X", extra, rawdata[i]);
> ++			sprintf(extra + strlen(extra), "%02X", rawdata[i]);
> + 			if ((i & 0xF) == 0xF) {
> + 				//				DBG_871X("\n");
> +-				sprintf(extra, "%s\n", extra);
> +-				sprintf(extra, "%s0x%02x\t", extra, i+1);
> ++				sprintf(extra + strlen(extra), "\n");
> ++				sprintf(extra + strlen(extra), "0x%02x\t", i+1);
> + 			} else if ((i & 0x7) == 0x7) {
> + 				//				DBG_871X("\t");
> +-				sprintf(extra, "%s \t", extra);
> ++				sprintf(extra + strlen(extra), " \t");
> + 			} else {
> + 				//				DBG_871X(" ");
> +-				sprintf(extra, "%s ", extra);
> ++				sprintf(extra + strlen(extra), " ");
> + 			}
> + 		}
> + 		//		DBG_871X("}\n");
> +@@ -9269,10 +9269,10 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		*extra = 0;
> + 		for (i=0; i<cnts; i++) {
> + //			DBG_871X("%02X", data[i]);
> +-			sprintf(extra, "%s%02X", extra, data[i]);
> ++			sprintf(extra + strlen(extra), "%02X", data[i]);
> + 			if (i != (cnts-1)) {
> + //				DBG_871X(":");
> +-				sprintf(extra,"%s:",extra);
> ++				sprintf(extra + strlen(extra), ":");
> + 			}
> + 		}
> + //		DBG_871X("}\n");
> +@@ -9330,10 +9330,10 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		*extra = 0;
> + 		for (i=0; i<cnts; i++) {
> + //			DBG_871X("0x%02x", data[i]);
> +-			sprintf(extra, "%s0x%02X", extra, data[i]);
> ++			sprintf(extra + strlen(extra), "0x%02X", data[i]);
> + 			if (i != (cnts-1)) {
> + //				DBG_871X(",");
> +-				sprintf(extra,"%s,",extra);
> ++				sprintf(extra + strlen(extra), ",");
> + 			}
> + 		}
> + //		DBG_871X("}\n");
> +@@ -9355,19 +9355,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i=0; i<512; i+=16) { // set 512 because the iwpriv's extra size have limit 0x7FF
> + //			DBG_871X("0x%03x\t", i);
> +-			sprintf(extra, "%s0x%03x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra,"%s\t",extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra, "%s\n", extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> + 	} else if (strcmp(tmp[0],"btbmap") == 0) {
> +@@ -9384,19 +9384,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i=512; i<1024 ; i+=16) {
> + //			DBG_871X("0x%03x\t", i);
> +-			sprintf(extra, "%s0x%03x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", data[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra,"%s\t",extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", data[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra, "%s\n", extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> + 	} else if (strcmp(tmp[0],"btrmap") == 0) {
> +@@ -9436,7 +9436,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + //		DBG_871X("%s: bt efuse data={", __FUNCTION__);
> + 		for (i=0; i<cnts; i++) {
> + //			DBG_871X("0x%02x ", data[i]);
> +-			sprintf(extra, "%s 0x%02X ", extra, data[i]);
> ++			sprintf(extra + strlen(extra), " 0x%02X ", data[i]);
> + 		}
> + //		DBG_871X("}\n");
> + 		DBG_871X(FUNC_ADPT_FMT ": BT MAC=[%s]\n", FUNC_ADPT_ARG(padapter), extra);
> +@@ -9445,19 +9445,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i=0; i<512; i+=16) {
> + //			DBG_871X("0x%03x\t", i);
> +-			sprintf(extra, "%s0x%03x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra, "%s\t", extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra, "%s\n", extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> + 	} else if (strcmp(tmp[0],"btbfake") == 0) {
> +@@ -9465,19 +9465,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i=512; i<1024; i+=16) {
> + //			DBG_871X("0x%03x\t", i);
> +-			sprintf(extra, "%s0x%03x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra, "%s\t", extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra, "%s\n", extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> + 	} else if (strcmp(tmp[0],"wlrfkmap")== 0) {
> +@@ -9485,19 +9485,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		sprintf(extra, "\n");
> + 		for (i=0; i<EFUSE_MAP_SIZE; i+=16) {
> + //			DBG_871X("\t0x%02x\t", i);
> +-			sprintf(extra, "%s0x%02x\t", extra, i);
> ++			sprintf(extra + strlen(extra), "0x%02x\t", i);
> + 			for (j=0; j<8; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
> ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> + 			}
> + //			DBG_871X("\t");
> +-			sprintf(extra, "%s\t", extra);
> ++			sprintf(extra + strlen(extra), "\t");
> + 			for (; j<16; j++) {
> + //				DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> +-				sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
> ++				sprintf(extra + strlen(extra), " %02X", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> + 			}
> + //			DBG_871X("\n");
> +-			sprintf(extra, "%s\n", extra);
> ++			sprintf(extra + strlen(extra), "\n");
> + 		}
> + //		DBG_871X("\n");
> +
> +@@ -9523,7 +9523,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		*extra = 0;
> + 		for (i=0; i<cnts; i++) {
> + 			DBG_871X("wlrfkrmap = 0x%02x \n", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
> +-			sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[addr+i]);
> ++			sprintf(extra + strlen(extra), "0x%02X ", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
> + 		}
> + 	} else if (strcmp(tmp[0],"btrfkrmap")== 0) {
> + 		if ((tmp[1]==NULL) || (tmp[2]==NULL)) {
> +@@ -9547,7 +9547,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> + 		*extra = 0;
> + 		for (i=0; i<cnts; i++) {
> + 			DBG_871X("wlrfkrmap = 0x%02x \n", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
> +-			sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
> ++			sprintf(extra + strlen(extra), "0x%02X ", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
> + 		}
> + 	} else {
> + 		sprintf(extra, "Command not found!");
> +@@ -10409,7 +10409,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
> + 			pnext++;
> + 			if ( *pnext != '\0' ) {
> + 				strtout = simple_strtoul (pnext , &ptmp, 16);
> +-				sprintf( extra, "%s %d" ,extra ,strtout );
> ++				sprintf(extra + strlen(extra), " %d"  ,strtout );
> + 			} else {
> + 				break;
> + 			}
> +@@ -10443,7 +10443,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
> + 			pnext++;
> + 			if ( *pnext != '\0' ) {
> + 				strtout = simple_strtoul (pnext , &ptmp, 16);
> +-				sprintf( extra, "%s %d" ,extra ,strtout );
> ++				sprintf(extra + strlen(extra), " %d"  ,strtout );
> + 			} else {
> + 				break;
> + 			}
> +@@ -10566,7 +10566,7 @@ static int rtw_mp_read_rf(struct net_device *dev,
> + 		pnext++;
> + 		if ( *pnext != '\0' ) {
> + 			strtou = simple_strtoul (pnext , &ptmp, 16);
> +-			sprintf( extra, "%s %d" ,extra ,strtou );
> ++			sprintf(extra + strlen(extra), " %d"  ,strtou );
> + 		} else {
> + 			break;
> + 		}
> +@@ -12155,14 +12155,14 @@ todo:
> + 				goto exit;
> +
> + #ifdef CONFIG_RTL8723A
> +-			sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i]& 0x3f));
> ++			sprintf(extra + strlen(extra), " %d ", (pMptCtx->mptOutBuf[i]& 0x3f));
> + #else
> +-			sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i]& 0x1f));
> ++			sprintf(extra + strlen(extra), " %d ", (pMptCtx->mptOutBuf[i]& 0x1f));
> + #endif
> + 		}
> + 	} else {
> + 		for (i=4; i<pMptCtx->mptOutLen; i++) {
> +-			sprintf(extra, "%s 0x%x ", extra, pMptCtx->mptOutBuf[i]);
> ++			sprintf(extra + strlen(extra), " 0x%x ", pMptCtx->mptOutBuf[i]);
> + 		}
> + 	}
> +
> +--
> +2.27.0
> +
Peter Seiderer Aug. 1, 2020, 9:40 p.m. UTC | #3
Hello Christian,

On Sat, 1 Aug 2020 23:34:10 +0200, Peter Seiderer <ps.report@gmx.net> wrote:

> Hello Christian,
>
>
> thanks for the patch, but...
>
> On Sat,  1 Aug 2020 13:37:49 -0700, Christian Stewart <christian@paral.in> wrote:
>
> > Fixes compile errors against certain kernels.
> >
> > Signed-off-by: Christian Stewart <christian@paral.in>
> > ---
> >  ...f-for-extending-string-which-causes-.patch | 336 ++++++++++++++++++
> >  1 file changed, 336 insertions(+)
> >  create mode 100644 package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> >
> > diff --git a/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > new file mode 100644
> > index 0000000000..6753eefdd9
> > --- /dev/null
> > +++ b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > @@ -0,0 +1,336 @@
> > +From cc3262a32ce326d89d597bb8557ce0da05240e98 Mon Sep 17 00:00:00 2001
> > +From: Coleman <omegacoleman@gmail.com>
> > +Date: Fri, 17 Jul 2020 08:53:00 +0800
> > +Subject: [PATCH 3/3] Fix using sprintf for extending string, which causes
> > + undefined behavior. (#334)
> > +
>
> The patch should have an note about the upstream source (see [1]), I suspect you
> toke the patch from [2]?

Or instead simple bump the package source version to the latest git commit
(as the patch is upstream committed)... ;-)

Regards,
Peter

>
> The patch itself should have your 'Signed-off-by', see [3]...
>
> With this fixed you can add my 'Reviewed-by'...
>
> Or maybe its worth to try some other 'upstream' sources, e.g. as
> openSUSE [4] does (mentioning previous [5] and [6]), or the first
> google search result [7] (did not find the time to dig into the
> different repositories to find out which one is the best)...
>
> Regards,
> Peter
>
>
> [1] https://buildroot.org/downloads/manual/manual.html#_integrating_patches_found_on_the_web
> [2] https://github.com/abperiasamy/rtl8812AU_8821AU_linux/commit/be57045a0933d64e958878696883e9cf998e1bf3.patch
> [3] https://buildroot.org/downloads/manual/manual.html#_format_and_licensing_of_the_package_patches
> [4] https://github.com/gordboy/rtl8812au
> [5] https://github.com/diederikdehaas/rtl8812AU
> [6] https://github.com/maurossi/rtl8812au/
> [7] https://github.com/gnab/rtl8812au
>
>
> > +---
> > + core/rtw_mp.c              |   2 +-
> > + os_dep/linux/ioctl_linux.c | 108 ++++++++++++++++++-------------------
> > + 2 files changed, 55 insertions(+), 55 deletions(-)
> > +
> > +diff --git a/core/rtw_mp.c b/core/rtw_mp.c
> > +index c2e400d..989bb3e 100644
> > +--- a/core/rtw_mp.c
> > ++++ b/core/rtw_mp.c
> > +@@ -1871,7 +1871,7 @@ u32 mp_query_psd(PADAPTER pAdapter, u8 *data)
> > + 		} else {
> > + 			psd_data = rtw_GetPSDData(pAdapter, i);
> > + 		}
> > +-		sprintf(data, "%s%x ", data, psd_data);
> > ++		sprintf(data + strlen(data), "%x ", psd_data);
> > + 		i++;
> > + 	}
> > +
> > +diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c
> > +index c74a153..9543fa3 100644
> > +--- a/os_dep/linux/ioctl_linux.c
> > ++++ b/os_dep/linux/ioctl_linux.c
> > +@@ -9080,19 +9080,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
> > + //			DBG_871X("0x%02x\t", i);
> > +-			sprintf(extra, "%s0x%02x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%02x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", data[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra, "%s\t", extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", data[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra,"%s\n",extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > + 	} else if (strcmp(tmp[0], "realmap") == 0) {
> > +@@ -9107,19 +9107,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
> > + //			DBG_871X("0x%02x\t", i);
> > +-			sprintf(extra, "%s0x%02x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%02x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", data[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra, "%s\t", extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", data[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra,"%s\n",extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > + 	} else if (strcmp(tmp[0], "rmap") == 0) {
> > +@@ -9158,7 +9158,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		*extra = 0;
> > + 		for (i=0; i<cnts; i++) {
> > + //			DBG_871X("0x%02x ", data[i]);
> > +-			sprintf(extra, "%s0x%02X ", extra, data[i]);
> > ++			sprintf(extra + strlen(extra), "0x%02X ", data[i]);
> > + 		}
> > + //		DBG_871X("}\n");
> > + 	} else if (strcmp(tmp[0], "realraw") == 0) {
> > +@@ -9174,17 +9174,17 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n0x00\t");
> > + 		for (i=0; i< mapLen; i++) {
> > + 			//			DBG_871X("%02X", rawdata[i]);
> > +-			sprintf(extra, "%s%02X", extra, rawdata[i]);
> > ++			sprintf(extra + strlen(extra), "%02X", rawdata[i]);
> > + 			if ((i & 0xF) == 0xF) {
> > + 				//				DBG_871X("\n");
> > +-				sprintf(extra, "%s\n", extra);
> > +-				sprintf(extra, "%s0x%02x\t", extra, i+1);
> > ++				sprintf(extra + strlen(extra), "\n");
> > ++				sprintf(extra + strlen(extra), "0x%02x\t", i+1);
> > + 			} else if ((i & 0x7) == 0x7) {
> > + 				//				DBG_871X("\t");
> > +-				sprintf(extra, "%s \t", extra);
> > ++				sprintf(extra + strlen(extra), " \t");
> > + 			} else {
> > + 				//				DBG_871X(" ");
> > +-				sprintf(extra, "%s ", extra);
> > ++				sprintf(extra + strlen(extra), " ");
> > + 			}
> > + 		}
> > + 		//		DBG_871X("}\n");
> > +@@ -9269,10 +9269,10 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		*extra = 0;
> > + 		for (i=0; i<cnts; i++) {
> > + //			DBG_871X("%02X", data[i]);
> > +-			sprintf(extra, "%s%02X", extra, data[i]);
> > ++			sprintf(extra + strlen(extra), "%02X", data[i]);
> > + 			if (i != (cnts-1)) {
> > + //				DBG_871X(":");
> > +-				sprintf(extra,"%s:",extra);
> > ++				sprintf(extra + strlen(extra), ":");
> > + 			}
> > + 		}
> > + //		DBG_871X("}\n");
> > +@@ -9330,10 +9330,10 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		*extra = 0;
> > + 		for (i=0; i<cnts; i++) {
> > + //			DBG_871X("0x%02x", data[i]);
> > +-			sprintf(extra, "%s0x%02X", extra, data[i]);
> > ++			sprintf(extra + strlen(extra), "0x%02X", data[i]);
> > + 			if (i != (cnts-1)) {
> > + //				DBG_871X(",");
> > +-				sprintf(extra,"%s,",extra);
> > ++				sprintf(extra + strlen(extra), ",");
> > + 			}
> > + 		}
> > + //		DBG_871X("}\n");
> > +@@ -9355,19 +9355,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i=0; i<512; i+=16) { // set 512 because the iwpriv's extra size have limit 0x7FF
> > + //			DBG_871X("0x%03x\t", i);
> > +-			sprintf(extra, "%s0x%03x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra,"%s\t",extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra, "%s\n", extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > + 	} else if (strcmp(tmp[0],"btbmap") == 0) {
> > +@@ -9384,19 +9384,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i=512; i<1024 ; i+=16) {
> > + //			DBG_871X("0x%03x\t", i);
> > +-			sprintf(extra, "%s0x%03x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", data[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra,"%s\t",extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", data[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra, "%s\n", extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > + 	} else if (strcmp(tmp[0],"btrmap") == 0) {
> > +@@ -9436,7 +9436,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + //		DBG_871X("%s: bt efuse data={", __FUNCTION__);
> > + 		for (i=0; i<cnts; i++) {
> > + //			DBG_871X("0x%02x ", data[i]);
> > +-			sprintf(extra, "%s 0x%02X ", extra, data[i]);
> > ++			sprintf(extra + strlen(extra), " 0x%02X ", data[i]);
> > + 		}
> > + //		DBG_871X("}\n");
> > + 		DBG_871X(FUNC_ADPT_FMT ": BT MAC=[%s]\n", FUNC_ADPT_ARG(padapter), extra);
> > +@@ -9445,19 +9445,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i=0; i<512; i+=16) {
> > + //			DBG_871X("0x%03x\t", i);
> > +-			sprintf(extra, "%s0x%03x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra, "%s\t", extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra, "%s\n", extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > + 	} else if (strcmp(tmp[0],"btbfake") == 0) {
> > +@@ -9465,19 +9465,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i=512; i<1024; i+=16) {
> > + //			DBG_871X("0x%03x\t", i);
> > +-			sprintf(extra, "%s0x%03x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%03x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra, "%s\t", extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra, "%s\n", extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > + 	} else if (strcmp(tmp[0],"wlrfkmap")== 0) {
> > +@@ -9485,19 +9485,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		sprintf(extra, "\n");
> > + 		for (i=0; i<EFUSE_MAP_SIZE; i+=16) {
> > + //			DBG_871X("\t0x%02x\t", i);
> > +-			sprintf(extra, "%s0x%02x\t", extra, i);
> > ++			sprintf(extra + strlen(extra), "0x%02x\t", i);
> > + 			for (j=0; j<8; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> > +-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
> > ++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> > + 			}
> > + //			DBG_871X("\t");
> > +-			sprintf(extra, "%s\t", extra);
> > ++			sprintf(extra + strlen(extra), "\t");
> > + 			for (; j<16; j++) {
> > + //				DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> > +-				sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
> > ++				sprintf(extra + strlen(extra), " %02X", pEfuseHal->fakeEfuseModifiedMap[i+j]);
> > + 			}
> > + //			DBG_871X("\n");
> > +-			sprintf(extra, "%s\n", extra);
> > ++			sprintf(extra + strlen(extra), "\n");
> > + 		}
> > + //		DBG_871X("\n");
> > +
> > +@@ -9523,7 +9523,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		*extra = 0;
> > + 		for (i=0; i<cnts; i++) {
> > + 			DBG_871X("wlrfkrmap = 0x%02x \n", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
> > +-			sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[addr+i]);
> > ++			sprintf(extra + strlen(extra), "0x%02X ", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
> > + 		}
> > + 	} else if (strcmp(tmp[0],"btrfkrmap")== 0) {
> > + 		if ((tmp[1]==NULL) || (tmp[2]==NULL)) {
> > +@@ -9547,7 +9547,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
> > + 		*extra = 0;
> > + 		for (i=0; i<cnts; i++) {
> > + 			DBG_871X("wlrfkrmap = 0x%02x \n", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
> > +-			sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
> > ++			sprintf(extra + strlen(extra), "0x%02X ", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
> > + 		}
> > + 	} else {
> > + 		sprintf(extra, "Command not found!");
> > +@@ -10409,7 +10409,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
> > + 			pnext++;
> > + 			if ( *pnext != '\0' ) {
> > + 				strtout = simple_strtoul (pnext , &ptmp, 16);
> > +-				sprintf( extra, "%s %d" ,extra ,strtout );
> > ++				sprintf(extra + strlen(extra), " %d"  ,strtout );
> > + 			} else {
> > + 				break;
> > + 			}
> > +@@ -10443,7 +10443,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
> > + 			pnext++;
> > + 			if ( *pnext != '\0' ) {
> > + 				strtout = simple_strtoul (pnext , &ptmp, 16);
> > +-				sprintf( extra, "%s %d" ,extra ,strtout );
> > ++				sprintf(extra + strlen(extra), " %d"  ,strtout );
> > + 			} else {
> > + 				break;
> > + 			}
> > +@@ -10566,7 +10566,7 @@ static int rtw_mp_read_rf(struct net_device *dev,
> > + 		pnext++;
> > + 		if ( *pnext != '\0' ) {
> > + 			strtou = simple_strtoul (pnext , &ptmp, 16);
> > +-			sprintf( extra, "%s %d" ,extra ,strtou );
> > ++			sprintf(extra + strlen(extra), " %d"  ,strtou );
> > + 		} else {
> > + 			break;
> > + 		}
> > +@@ -12155,14 +12155,14 @@ todo:
> > + 				goto exit;
> > +
> > + #ifdef CONFIG_RTL8723A
> > +-			sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i]& 0x3f));
> > ++			sprintf(extra + strlen(extra), " %d ", (pMptCtx->mptOutBuf[i]& 0x3f));
> > + #else
> > +-			sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i]& 0x1f));
> > ++			sprintf(extra + strlen(extra), " %d ", (pMptCtx->mptOutBuf[i]& 0x1f));
> > + #endif
> > + 		}
> > + 	} else {
> > + 		for (i=4; i<pMptCtx->mptOutLen; i++) {
> > +-			sprintf(extra, "%s 0x%x ", extra, pMptCtx->mptOutBuf[i]);
> > ++			sprintf(extra + strlen(extra), " 0x%x ", pMptCtx->mptOutBuf[i]);
> > + 		}
> > + 	}
> > +
> > +--
> > +2.27.0
> > +
>
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Christian Stewart Aug. 1, 2020, 9:43 p.m. UTC | #4
Hi Peter,



On Sat, Aug 1, 2020, 2:40 PM Peter Seiderer <ps.report@gmx.net> wrote:

> Hello Christian,
>
> On Sat, 1 Aug 2020 23:34:10 +0200, Peter Seiderer <ps.report@gmx.net>
> wrote:
>
> > Hello Christian,
> >
> >
> > thanks for the patch, but...
> >
> > On Sat,  1 Aug 2020 13:37:49 -0700, Christian Stewart <
> christian@paral.in> wrote:
> >
> > > Fixes compile errors against certain kernels.
> > >
> > > Signed-off-by: Christian Stewart <christian@paral.in>
> > > ---
> > >  ...f-for-extending-string-which-causes-.patch | 336 ++++++++++++++++++
> > >  1 file changed, 336 insertions(+)
> > >  create mode 100644
> package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > >
> > > diff --git
> a/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > > new file mode 100644
> > > index 0000000000..6753eefdd9
> > > --- /dev/null
> > > +++
> b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > > @@ -0,0 +1,336 @@
> > > +From cc3262a32ce326d89d597bb8557ce0da05240e98 Mon Sep 17 00:00:00 2001
> > > +From: Coleman <omegacoleman@gmail.com>
> > > +Date: Fri, 17 Jul 2020 08:53:00 +0800
> > > +Subject: [PATCH 3/3] Fix using sprintf for extending string, which
> causes
> > > + undefined behavior. (#334)
> > > +
> >
> > The patch should have an note about the upstream source (see [1]), I
> suspect you
> > toke the patch from [2]?
>
> Or instead simple bump the package source version to the latest git commit
> (as the patch is upstream committed)... ;-)
>

Can't do. The upstream has a commit that we don't follow. Apparently it has
issues. Look at the PR on the repo.

Thanks,
christian
Christian Stewart Aug. 1, 2020, 9:51 p.m. UTC | #5
Hi Peter,


On Sat, Aug 1, 2020, 2:34 PM Peter Seiderer <ps.report@gmx.net> wrote:

> thanks for the patch, but...


> maybe its worth to try some other 'upstream' sources, e.g. as
> openSUSE [4] does (mentioning previous [5] and [6]), or the first
> google search result [7] (did not find the time to dig into the
> different repositories to find out which one is the best)...


We've been through a number of these over the years. I would not recommend
switching to another unless there's a specific reason. As far as I know the
current configuration/upstream works fine with USB RTL cards.

Best,
Christian
Christian Stewart Aug. 2, 2020, 12:33 a.m. UTC | #6
Hi Peter,

On Sat, Aug 1, 2020 at 2:51 PM Christian Stewart <christian@paral.in> wrote:
>
> Hi Peter,
>
>
> On Sat, Aug 1, 2020, 2:34 PM Peter Seiderer <ps.report@gmx.net> wrote:
>>
>> maybe its worth to try some other 'upstream' sources, e.g. as
>> openSUSE [4] does (mentioning previous [5] and [6]), or the first
>> google search result [7] (did not find the time to dig into the
>> different repositories to find out which one is the best)...
>
>
> We've been through a number of these over the years. I would not recommend switching to another unless there's a specific reason. As far as I know the current configuration/upstream works fine with USB RTL cards.

See: https://github.com/paralin/buildroot/commit/af8d30846e71e378fdcdb632bbbbfe0aaf7bb669

Just out of curiosity I made a patch switching to the aircrack fork,
but there were some errors at the install step, for example:

depmod: WARNING: /target/lib/modules/4.14.180/extra/88XXau.ko needs
unknown symbol cfg80211_unlink_bss
depmod: WARNING: /target/lib/modules/4.14.180/extra/88XXau.ko needs
unknown symbol ieee80211

Even though the CFG80211 options are enabled in the kernel, and the
build passes with the old fork.

Maybe there are some path issues going on there.

Looks like the aircrack fork may have better support for packet injection?

Best,
Christian
Peter Seiderer Aug. 2, 2020, 10:51 a.m. UTC | #7
Hello Christian,

On Sat, 1 Aug 2020 14:43:32 -0700, Christian Stewart <christian@paral.in> wrote:

> Hi Peter,
>
>
>
> On Sat, Aug 1, 2020, 2:40 PM Peter Seiderer <ps.report@gmx.net> wrote:
>
> > Hello Christian,
> >
> > On Sat, 1 Aug 2020 23:34:10 +0200, Peter Seiderer <ps.report@gmx.net>
> > wrote:
> >
> > > Hello Christian,
> > >
> > >
> > > thanks for the patch, but...
> > >
> > > On Sat,  1 Aug 2020 13:37:49 -0700, Christian Stewart <
> > christian@paral.in> wrote:
> > >
> > > > Fixes compile errors against certain kernels.
> > > >
> > > > Signed-off-by: Christian Stewart <christian@paral.in>
> > > > ---
> > > >  ...f-for-extending-string-which-causes-.patch | 336 ++++++++++++++++++
> > > >  1 file changed, 336 insertions(+)
> > > >  create mode 100644
> > package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > > >
> > > > diff --git
> > a/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > > > new file mode 100644
> > > > index 0000000000..6753eefdd9
> > > > --- /dev/null
> > > > +++
> > b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
> > > > @@ -0,0 +1,336 @@
> > > > +From cc3262a32ce326d89d597bb8557ce0da05240e98 Mon Sep 17 00:00:00 2001
> > > > +From: Coleman <omegacoleman@gmail.com>
> > > > +Date: Fri, 17 Jul 2020 08:53:00 +0800
> > > > +Subject: [PATCH 3/3] Fix using sprintf for extending string, which
> > causes
> > > > + undefined behavior. (#334)
> > > > +
> > >
> > > The patch should have an note about the upstream source (see [1]), I
> > suspect you
> > > toke the patch from [2]?
> >
> > Or instead simple bump the package source version to the latest git commit
> > (as the patch is upstream committed)... ;-)
> >
>
> Can't do. The upstream has a commit that we don't follow. Apparently it has
> issues. Look at the PR on the repo.

Yes, your are right (and thanks for remind me of that point), maybe worth
a short remark at the commit log...

Regards,
Peter

>
> Thanks,
> christian
Peter Seiderer Aug. 2, 2020, 10:57 a.m. UTC | #8
Hello Christian,

On Sat, 1 Aug 2020 17:33:48 -0700, Christian Stewart <christian@paral.in> wrote:

> Hi Peter,
>
> On Sat, Aug 1, 2020 at 2:51 PM Christian Stewart <christian@paral.in> wrote:
> >
> > Hi Peter,
> >
> >
> > On Sat, Aug 1, 2020, 2:34 PM Peter Seiderer <ps.report@gmx.net> wrote:
> >>
> >> maybe its worth to try some other 'upstream' sources, e.g. as
> >> openSUSE [4] does (mentioning previous [5] and [6]), or the first
> >> google search result [7] (did not find the time to dig into the
> >> different repositories to find out which one is the best)...
> >
> >
> > We've been through a number of these over the years. I would not recommend switching to another unless there's a specific reason. As far as I know the current configuration/upstream works fine with USB RTL cards.

Did only a quick test some weeks ago, trying the IBSS mode and to get wifibroadcast
to work (both did not work out as far as I remember, so switched to some other cards)...

>
> See: https://github.com/paralin/buildroot/commit/af8d30846e71e378fdcdb632bbbbfe0aaf7bb669
>

Will take a look at it (if I find some spare time ;-)) and try it out....

Regards,
Peter

> Just out of curiosity I made a patch switching to the aircrack fork,
> but there were some errors at the install step, for example:
>
> depmod: WARNING: /target/lib/modules/4.14.180/extra/88XXau.ko needs
> unknown symbol cfg80211_unlink_bss
> depmod: WARNING: /target/lib/modules/4.14.180/extra/88XXau.ko needs
> unknown symbol ieee80211
>
> Even though the CFG80211 options are enabled in the kernel, and the
> build passes with the old fork.
>
> Maybe there are some path issues going on there.
>
> Looks like the aircrack fork may have better support for packet injection?
>
> Best,
> Christian
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Christian Stewart Aug. 2, 2020, 4 p.m. UTC | #9
Hey Peter,

On Sun, Aug 2, 2020 at 3:58 AM Peter Seiderer <ps.report@gmx.net> wrote:
> Did only a quick test some weeks ago, trying the IBSS mode and to get wifibroadcast
> to work (both did not work out as far as I remember, so switched to some other cards)...

I have a rtl8821au card in the mail to test with (odroid USB module).

By all means, if the aircrack fork will fix these features, then let's
switch it.

> > See: https://github.com/paralin/buildroot/commit/af8d30846e71e378fdcdb632bbbbfe0aaf7bb669
>
> Will take a look at it (if I find some spare time ;-)) and try it out...

Appreciated, perhaps you (or someone else who knows) could have a look
at the depmod errors I was seeing with the fork if you have a moment.

Best regards,
Christian
diff mbox series

Patch

diff --git a/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
new file mode 100644
index 0000000000..6753eefdd9
--- /dev/null
+++ b/package/rtl8821au/0003-Fix-using-sprintf-for-extending-string-which-causes-.patch
@@ -0,0 +1,336 @@ 
+From cc3262a32ce326d89d597bb8557ce0da05240e98 Mon Sep 17 00:00:00 2001
+From: Coleman <omegacoleman@gmail.com>
+Date: Fri, 17 Jul 2020 08:53:00 +0800
+Subject: [PATCH 3/3] Fix using sprintf for extending string, which causes
+ undefined behavior. (#334)
+
+---
+ core/rtw_mp.c              |   2 +-
+ os_dep/linux/ioctl_linux.c | 108 ++++++++++++++++++-------------------
+ 2 files changed, 55 insertions(+), 55 deletions(-)
+
+diff --git a/core/rtw_mp.c b/core/rtw_mp.c
+index c2e400d..989bb3e 100644
+--- a/core/rtw_mp.c
++++ b/core/rtw_mp.c
+@@ -1871,7 +1871,7 @@ u32 mp_query_psd(PADAPTER pAdapter, u8 *data)
+ 		} else {
+ 			psd_data = rtw_GetPSDData(pAdapter, i);
+ 		}
+-		sprintf(data, "%s%x ", data, psd_data);
++		sprintf(data + strlen(data), "%x ", psd_data);
+ 		i++;
+ 	}
+ 
+diff --git a/os_dep/linux/ioctl_linux.c b/os_dep/linux/ioctl_linux.c
+index c74a153..9543fa3 100644
+--- a/os_dep/linux/ioctl_linux.c
++++ b/os_dep/linux/ioctl_linux.c
+@@ -9080,19 +9080,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
+ //			DBG_871X("0x%02x\t", i);
+-			sprintf(extra, "%s0x%02x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%02x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", data[i+j]);
+-				sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra, "%s\t", extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", data[i+j]);
+-				sprintf(extra, "%s%02X ", extra, PROMContent[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra,"%s\n",extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 	} else if (strcmp(tmp[0], "realmap") == 0) {
+@@ -9107,19 +9107,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i = 0; i < EFUSE_MAP_SIZE; i += 16) {
+ //			DBG_871X("0x%02x\t", i);
+-			sprintf(extra, "%s0x%02x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%02x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", data[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra, "%s\t", extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", data[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseInitMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra,"%s\n",extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 	} else if (strcmp(tmp[0], "rmap") == 0) {
+@@ -9158,7 +9158,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		*extra = 0;
+ 		for (i=0; i<cnts; i++) {
+ //			DBG_871X("0x%02x ", data[i]);
+-			sprintf(extra, "%s0x%02X ", extra, data[i]);
++			sprintf(extra + strlen(extra), "0x%02X ", data[i]);
+ 		}
+ //		DBG_871X("}\n");
+ 	} else if (strcmp(tmp[0], "realraw") == 0) {
+@@ -9174,17 +9174,17 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n0x00\t");
+ 		for (i=0; i< mapLen; i++) {
+ 			//			DBG_871X("%02X", rawdata[i]);
+-			sprintf(extra, "%s%02X", extra, rawdata[i]);
++			sprintf(extra + strlen(extra), "%02X", rawdata[i]);
+ 			if ((i & 0xF) == 0xF) {
+ 				//				DBG_871X("\n");
+-				sprintf(extra, "%s\n", extra);
+-				sprintf(extra, "%s0x%02x\t", extra, i+1);
++				sprintf(extra + strlen(extra), "\n");
++				sprintf(extra + strlen(extra), "0x%02x\t", i+1);
+ 			} else if ((i & 0x7) == 0x7) {
+ 				//				DBG_871X("\t");
+-				sprintf(extra, "%s \t", extra);
++				sprintf(extra + strlen(extra), " \t");
+ 			} else {
+ 				//				DBG_871X(" ");
+-				sprintf(extra, "%s ", extra);
++				sprintf(extra + strlen(extra), " ");
+ 			}
+ 		}
+ 		//		DBG_871X("}\n");
+@@ -9269,10 +9269,10 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		*extra = 0;
+ 		for (i=0; i<cnts; i++) {
+ //			DBG_871X("%02X", data[i]);
+-			sprintf(extra, "%s%02X", extra, data[i]);
++			sprintf(extra + strlen(extra), "%02X", data[i]);
+ 			if (i != (cnts-1)) {
+ //				DBG_871X(":");
+-				sprintf(extra,"%s:",extra);
++				sprintf(extra + strlen(extra), ":");
+ 			}
+ 		}
+ //		DBG_871X("}\n");
+@@ -9330,10 +9330,10 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		*extra = 0;
+ 		for (i=0; i<cnts; i++) {
+ //			DBG_871X("0x%02x", data[i]);
+-			sprintf(extra, "%s0x%02X", extra, data[i]);
++			sprintf(extra + strlen(extra), "0x%02X", data[i]);
+ 			if (i != (cnts-1)) {
+ //				DBG_871X(",");
+-				sprintf(extra,"%s,",extra);
++				sprintf(extra + strlen(extra), ",");
+ 			}
+ 		}
+ //		DBG_871X("}\n");
+@@ -9355,19 +9355,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i=0; i<512; i+=16) { // set 512 because the iwpriv's extra size have limit 0x7FF
+ //			DBG_871X("0x%03x\t", i);
+-			sprintf(extra, "%s0x%03x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%03x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra,"%s\t",extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra, "%s\n", extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 	} else if (strcmp(tmp[0],"btbmap") == 0) {
+@@ -9384,19 +9384,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i=512; i<1024 ; i+=16) {
+ //			DBG_871X("0x%03x\t", i);
+-			sprintf(extra, "%s0x%03x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%03x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", data[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra,"%s\t",extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", data[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->BTEfuseInitMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra, "%s\n", extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 	} else if (strcmp(tmp[0],"btrmap") == 0) {
+@@ -9436,7 +9436,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ //		DBG_871X("%s: bt efuse data={", __FUNCTION__);
+ 		for (i=0; i<cnts; i++) {
+ //			DBG_871X("0x%02x ", data[i]);
+-			sprintf(extra, "%s 0x%02X ", extra, data[i]);
++			sprintf(extra + strlen(extra), " 0x%02X ", data[i]);
+ 		}
+ //		DBG_871X("}\n");
+ 		DBG_871X(FUNC_ADPT_FMT ": BT MAC=[%s]\n", FUNC_ADPT_ARG(padapter), extra);
+@@ -9445,19 +9445,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i=0; i<512; i+=16) {
+ //			DBG_871X("0x%03x\t", i);
+-			sprintf(extra, "%s0x%03x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%03x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra, "%s\t", extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra, "%s\n", extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 	} else if (strcmp(tmp[0],"btbfake") == 0) {
+@@ -9465,19 +9465,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i=512; i<1024; i+=16) {
+ //			DBG_871X("0x%03x\t", i);
+-			sprintf(extra, "%s0x%03x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%03x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra, "%s\t", extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra, "%s\n", extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 	} else if (strcmp(tmp[0],"wlrfkmap")== 0) {
+@@ -9485,19 +9485,19 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		sprintf(extra, "\n");
+ 		for (i=0; i<EFUSE_MAP_SIZE; i+=16) {
+ //			DBG_871X("\t0x%02x\t", i);
+-			sprintf(extra, "%s0x%02x\t", extra, i);
++			sprintf(extra + strlen(extra), "0x%02x\t", i);
+ 			for (j=0; j<8; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
+-				sprintf(extra, "%s%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
++				sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
+ 			}
+ //			DBG_871X("\t");
+-			sprintf(extra, "%s\t", extra);
++			sprintf(extra + strlen(extra), "\t");
+ 			for (; j<16; j++) {
+ //				DBG_871X("%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]);
+-				sprintf(extra, "%s %02X", extra, pEfuseHal->fakeEfuseModifiedMap[i+j]);
++				sprintf(extra + strlen(extra), " %02X", pEfuseHal->fakeEfuseModifiedMap[i+j]);
+ 			}
+ //			DBG_871X("\n");
+-			sprintf(extra, "%s\n", extra);
++			sprintf(extra + strlen(extra), "\n");
+ 		}
+ //		DBG_871X("\n");
+ 
+@@ -9523,7 +9523,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		*extra = 0;
+ 		for (i=0; i<cnts; i++) {
+ 			DBG_871X("wlrfkrmap = 0x%02x \n", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
+-			sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeEfuseModifiedMap[addr+i]);
++			sprintf(extra + strlen(extra), "0x%02X ", pEfuseHal->fakeEfuseModifiedMap[addr+i]);
+ 		}
+ 	} else if (strcmp(tmp[0],"btrfkrmap")== 0) {
+ 		if ((tmp[1]==NULL) || (tmp[2]==NULL)) {
+@@ -9547,7 +9547,7 @@ static int rtw_mp_efuse_get(struct net_device *dev,
+ 		*extra = 0;
+ 		for (i=0; i<cnts; i++) {
+ 			DBG_871X("wlrfkrmap = 0x%02x \n", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
+-			sprintf(extra, "%s0x%02X ", extra, pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
++			sprintf(extra + strlen(extra), "0x%02X ", pEfuseHal->fakeBTEfuseModifiedMap[addr+i]);
+ 		}
+ 	} else {
+ 		sprintf(extra, "Command not found!");
+@@ -10409,7 +10409,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
+ 			pnext++;
+ 			if ( *pnext != '\0' ) {
+ 				strtout = simple_strtoul (pnext , &ptmp, 16);
+-				sprintf( extra, "%s %d" ,extra ,strtout );
++				sprintf(extra + strlen(extra), " %d"  ,strtout );
+ 			} else {
+ 				break;
+ 			}
+@@ -10443,7 +10443,7 @@ static int rtw_mp_read_reg(struct net_device *dev,
+ 			pnext++;
+ 			if ( *pnext != '\0' ) {
+ 				strtout = simple_strtoul (pnext , &ptmp, 16);
+-				sprintf( extra, "%s %d" ,extra ,strtout );
++				sprintf(extra + strlen(extra), " %d"  ,strtout );
+ 			} else {
+ 				break;
+ 			}
+@@ -10566,7 +10566,7 @@ static int rtw_mp_read_rf(struct net_device *dev,
+ 		pnext++;
+ 		if ( *pnext != '\0' ) {
+ 			strtou = simple_strtoul (pnext , &ptmp, 16);
+-			sprintf( extra, "%s %d" ,extra ,strtou );
++			sprintf(extra + strlen(extra), " %d"  ,strtou );
+ 		} else {
+ 			break;
+ 		}
+@@ -12155,14 +12155,14 @@ todo:
+ 				goto exit;
+ 
+ #ifdef CONFIG_RTL8723A
+-			sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i]& 0x3f));
++			sprintf(extra + strlen(extra), " %d ", (pMptCtx->mptOutBuf[i]& 0x3f));
+ #else
+-			sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i]& 0x1f));
++			sprintf(extra + strlen(extra), " %d ", (pMptCtx->mptOutBuf[i]& 0x1f));
+ #endif
+ 		}
+ 	} else {
+ 		for (i=4; i<pMptCtx->mptOutLen; i++) {
+-			sprintf(extra, "%s 0x%x ", extra, pMptCtx->mptOutBuf[i]);
++			sprintf(extra + strlen(extra), " 0x%x ", pMptCtx->mptOutBuf[i]);
+ 		}
+ 	}
+ 
+-- 
+2.27.0
+