Commit 32c976bc authored by Anders Kaseorg's avatar Anders Kaseorg Committed by Greg Kroah-Hartman

Staging: rt2860: Don't call sprintf() with overlapping input and output.

The use of sprintf() to append to a buffer, as in
  sprintf(buf, "%sEntry: %d\n", buf, i)
is not valid according to C99 ("If copying takes place between objects
that overlap, the behavior is undefined.").  It breaks at least in
userspace under gcc -D_FORTIFY_SOURCE.  Replace this construct with
  sprintf(buf + strlen(buf), "Entry: %d\n", i)

This patch was automatically generated using
  perl -0pe 's/(sprintf\s*\(\s*([^,]*))(\s*,\s*")%s((?:[^"\\]|\\.)*"\s*,)\s*\2\s*,/$1 + strlen($2)$3$4/g'
  perl -0pe 's/(snprintf\s*\(\s*([^,]*))(\s*,[^,]*?)(\s*,\s*")%s((?:[^"\\]|\\.)*"\s*,)\s*\2\s*,/$1 + strlen($2)$3 - strlen($2)$4$5/g'
Signed-off-by: default avatarAnders Kaseorg <andersk@mit.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent d75b81a8
...@@ -2911,7 +2911,7 @@ INT RTMPShowCfgValue( ...@@ -2911,7 +2911,7 @@ INT RTMPShowCfgValue(
{ {
sprintf(pBuf, "\n"); sprintf(pBuf, "\n");
for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++) for (PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC = RTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name; PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC++)
sprintf(pBuf, "%s%s\n", pBuf, PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name); sprintf(pBuf + strlen(pBuf), "%s\n", PRTMP_PRIVATE_STA_SHOW_CFG_VALUE_PROC->name);
} }
return Status; return Status;
......
...@@ -1791,7 +1791,7 @@ int wext_notify_event_assoc( ...@@ -1791,7 +1791,7 @@ int wext_notify_event_assoc(
wrqu.data.length = (pAd->StaCfg.ReqVarIELen*2) + 17; wrqu.data.length = (pAd->StaCfg.ReqVarIELen*2) + 17;
sprintf(custom, "ASSOCINFO(ReqIEs="); sprintf(custom, "ASSOCINFO(ReqIEs=");
for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++) for (idx=0; idx<pAd->StaCfg.ReqVarIELen; idx++)
sprintf(custom, "%s%02x", custom, pAd->StaCfg.ReqVarIEs[idx]); sprintf(custom + strlen(custom), "%02x", pAd->StaCfg.ReqVarIEs[idx]);
wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom); wireless_send_event(pAd->net_dev, IWEVCUSTOM, &wrqu, custom);
} }
else else
......
...@@ -1360,7 +1360,7 @@ int rt_ioctl_giwscan(struct net_device *dev, ...@@ -1360,7 +1360,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7; iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].WpaIE.IELen * 2) + 7;
NdisMoveMemory(custom, "wpa_ie=", 7); NdisMoveMemory(custom, "wpa_ie=", 7);
for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++) for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].WpaIE.IELen; idx++)
sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]); sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].WpaIE.IE[idx]);
previous_ev = current_ev; previous_ev = current_ev;
current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
if (current_ev == previous_ev) if (current_ev == previous_ev)
...@@ -1380,7 +1380,7 @@ int rt_ioctl_giwscan(struct net_device *dev, ...@@ -1380,7 +1380,7 @@ int rt_ioctl_giwscan(struct net_device *dev,
iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7; iwe.u.data.length = (pAdapter->ScanTab.BssEntry[i].RsnIE.IELen * 2) + 7;
NdisMoveMemory(custom, "rsn_ie=", 7); NdisMoveMemory(custom, "rsn_ie=", 7);
for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++) for (idx = 0; idx < pAdapter->ScanTab.BssEntry[i].RsnIE.IELen; idx++)
sprintf(custom, "%s%02x", custom, pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]); sprintf(custom + strlen(custom), "%02x", pAdapter->ScanTab.BssEntry[i].RsnIE.IE[idx]);
previous_ev = current_ev; previous_ev = current_ev;
current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom); current_ev = IWE_STREAM_ADD_POINT(info, current_ev, end_buf, &iwe, custom);
if (current_ev == previous_ev) if (current_ev == previous_ev)
...@@ -2022,8 +2022,7 @@ void getBaInfo( ...@@ -2022,8 +2022,7 @@ void getBaInfo(
if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC)) if (((pEntry->ValidAsCLI || pEntry->ValidAsApCli) && (pEntry->Sst == SST_ASSOC))
|| (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh)) || (pEntry->ValidAsWDS) || (pEntry->ValidAsMesh))
{ {
sprintf(pOutBuf, "%s\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n", sprintf(pOutBuf + strlen(pOutBuf), "\n%02X:%02X:%02X:%02X:%02X:%02X (Aid = %d) (AP) -\n",
pOutBuf,
pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2], pEntry->Addr[0], pEntry->Addr[1], pEntry->Addr[2],
pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid); pEntry->Addr[3], pEntry->Addr[4], pEntry->Addr[5], pEntry->Aid);
...@@ -2033,7 +2032,7 @@ void getBaInfo( ...@@ -2033,7 +2032,7 @@ void getBaInfo(
if (pEntry->BARecWcidArray[j] != 0) if (pEntry->BARecWcidArray[j] != 0)
{ {
pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]]; pRecBAEntry =&pAd->BATable.BARecEntry[pEntry->BARecWcidArray[j]];
sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", pOutBuf, j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen); sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, LastIndSeq=%d, ReorderingPkts=%d\n", j, pRecBAEntry->BAWinSize, pRecBAEntry->LastIndSeq, pRecBAEntry->list.qlen);
} }
} }
sprintf(pOutBuf, "%s\n", pOutBuf); sprintf(pOutBuf, "%s\n", pOutBuf);
...@@ -2044,7 +2043,7 @@ void getBaInfo( ...@@ -2044,7 +2043,7 @@ void getBaInfo(
if (pEntry->BAOriWcidArray[j] != 0) if (pEntry->BAOriWcidArray[j] != 0)
{ {
pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]]; pOriBAEntry =&pAd->BATable.BAOriEntry[pEntry->BAOriWcidArray[j]];
sprintf(pOutBuf, "%sTID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", pOutBuf, j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]); sprintf(pOutBuf + strlen(pOutBuf), "TID=%d, BAWinSize=%d, StartSeq=%d, CurTxSeq=%d\n", j, pOriBAEntry->BAWinSize, pOriBAEntry->Sequence, pEntry->TxSeq[j]);
} }
} }
sprintf(pOutBuf, "%s\n\n", pOutBuf); sprintf(pOutBuf, "%s\n\n", pOutBuf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment