-
Notifications
You must be signed in to change notification settings - Fork 40
fix: [Net-Wakeup] The net card can not wakeup. #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: [Net-Wakeup] The net card can not wakeup. #506
Conversation
-- Code Logic error, "sizeof(logicalName::toStdString().c_str())" always return 8, not the length of logicalName. -- So, When the length more than 8, the net card will can not find. Log: fix issue Bug: https://pms.uniontech.com/bug-view-326565.html
Reviewer's GuideThis PR addresses a logic error in interface name copying by replacing the incorrect sizeof-based length on c_str() with a safe copy using IFNAMSIZ-1 and QByteArray conversion, adds explicit zeroing of wolinfo to eliminate uninitialized data, and ensures null termination of ifr.ifr_name in both wakeOnLanIsOpen and setWakeOnLan. Class diagram for WakeupUtils changesclassDiagram
class WakeupUtils {
+EthStatus wakeOnLanIsOpen(const QString &logicalName)
+bool setWakeOnLan(const QString &logicalName, bool open)
}
WakeupUtils : -strncpy(ifr.ifr_name, logicalName.toStdString().c_str(), sizeof(logicalName.toStdString().c_str()))
WakeupUtils : +QByteArray nameBytes = logicalName.toLocal8Bit()
WakeupUtils : +strncpy(ifr.ifr_name, nameBytes.constData(), IFNAMSIZ - 1)
WakeupUtils : +ifr.ifr_name[IFNAMSIZ - 1] = '\0'
WakeupUtils : +memset(&wolinfo, 0, sizeof(wolinfo))
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
deepin pr auto review代码审查意见:
综上所述,建议对代码进行重构,提取公共逻辑,增加错误处理和资源管理,并确保代码风格的一致性。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @GongHeng2017 - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: GongHeng2017, max-lvs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
|
This pr cannot be merged! (status: unstable) |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
6961768
into
linuxdeepin:develop/eagle
-- Code Logic error, "sizeof(logicalName::toStdString().c_str())" always return 8,
not the length of logicalName.
-- So, When the length more than 8, the net card will can not find.
Log: fix issue
Bug: https://pms.uniontech.com/bug-view-326565.html
Summary by Sourcery
Fix net card wake-on-lan detection for interface names longer than 8 characters by properly initializing wolinfo and correctly copying logicalName into ifr.ifr_name with a fixed-size limit and null termination.
Bug Fixes: