Skip to content

Commit e86e50e

Browse files
lJxDababdeepin-bot[bot]
authored andcommitted
fix: the overflow bug of the stack in deepin-devicemanager
ioctlEnableNetwork-> ioctlOperateNetworkLogicalName, in this function directly to the user input parameter path, strcpy gives ifr.ifr_name a stack overflow Log: overflow bug (strcpy) (latest change) Bug: https://pms.uniontech.com/bug-view-253863.html
1 parent 7b620c2 commit e86e50e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol

deepin-devicemanager-server/deepin-devicecontrol/src/enablecontrol/enableutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ bool EnableUtils::ioctlOperateNetworkLogicalName(const QString &logicalName, boo
152152
if (fd < 0)
153153
return false;
154154
struct ifreq ifr;
155-
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),strlen(ifr.ifr_name));
156-
155+
strncpy(ifr.ifr_name, logicalName.toStdString().c_str(),IFNAMSIZ);
156+
ifr.ifr_name[IFNAMSIZ - 1] = '\0';
157157
short flag;
158158
if (enable) {
159159
flag = IFF_UP | IFF_PROMISC;

0 commit comments

Comments
 (0)