-
Notifications
You must be signed in to change notification settings - Fork 140
fix: Fix the biometric authentication refresh not being timely. #2652
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
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pengfeixx The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Reviewer's GuideThis PR ensures the biometric authentication status is refreshed immediately by invoking a new handler during driver info retrieval and introducing a dedicated method to update the model state and enrollment list based on the default device availability. Sequence diagram for biometric authentication refresh on driver info retrievalsequenceDiagram
participant CharaMangerWorker
participant CharaMangerInter
participant CharaMangerModel
participant SystemUser
CharaMangerWorker->>CharaMangerInter: driverInfo()
CharaMangerWorker->>CharaMangerInter: defaultDevice()
CharaMangerWorker->>CharaMangerWorker: refreshFingerDriverStatus(defaultDevice)
alt defaultDevice is valid
CharaMangerWorker->>SystemUser: getuid() / getpwuid()
CharaMangerWorker->>CharaMangerWorker: refreshFingerEnrollList(userId)
else defaultDevice is not valid
CharaMangerWorker->>CharaMangerModel: setThumbsList([])
end
CharaMangerWorker->>CharaMangerModel: setFingerVaild(isFingerValid)
Class diagram for updated CharaMangerWorker methodsclassDiagram
class CharaMangerWorker {
+void refreshDriverInfo()
+void refreshFingerDriverStatus(const QString &defaultDevice)
-CharaMangerModel *m_model
}
class CharaMangerModel {
+void setFingerVaild(bool)
+void setThumbsList(QStringList)
}
CharaMangerWorker --> CharaMangerModel
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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 there - I've reviewed your changes - here's some feedback:
- Add a null check for getpwuid(getuid()) before dereferencing pws to avoid potential crashes if the user lookup fails.
- Consider extracting the user-name retrieval into a separate helper or injecting it, so refreshFingerDriverStatus only handles driver state logic and not system calls.
- There’s a typo in the model setter and usage:
setFingerVaildshould besetFingerValidfor consistency and readability.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Add a null check for getpwuid(getuid()) before dereferencing pws to avoid potential crashes if the user lookup fails.
- Consider extracting the user-name retrieval into a separate helper or injecting it, so refreshFingerDriverStatus only handles driver state logic and not system calls.
- There’s a typo in the model setter and usage: `setFingerVaild` should be `setFingerValid` for consistency and readability.
## Individual Comments
### Comment 1
<location> `src/plugin-authentication/operation/charamangerworker.cpp:427` </location>
<code_context>
+ if (isFingerValid) {
+ struct passwd *pws;
+ QString userId;
+ pws = getpwuid(getuid());
+ userId = QString(pws->pw_name);
+ refreshFingerEnrollList(userId);
+ } else {
</code_context>
<issue_to_address>
Potential null pointer dereference with getpwuid.
Add a null check for pws before accessing pw_name to prevent crashes if getpwuid returns nullptr.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| pws = getpwuid(getuid()); | ||
| userId = QString(pws->pw_name); |
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.
issue (bug_risk): Potential null pointer dereference with getpwuid.
Add a null check for pws before accessing pw_name to prevent crashes if getpwuid returns nullptr.
Fix the biometric authentication refresh not being timely. Log: Fix the biometric authentication refresh not being timely. pms: BUG-332419
df3e809 to
f7c452c
Compare
deepin pr auto review我对这段代码进行了审查,发现了一些可以改进的地方:
if (pws == nullptr) {
qWarning() << "Failed to get user information";
return;
}
改进建议: void CharaMangerWorker::refreshDriverInfo()
{
auto driverInfo = m_charaMangerInter->driverInfo();
predefineDriverInfo(driverInfo);
auto defaultDevice = m_charaMangerInter->defaultDevice();
if (!defaultDevice.isEmpty()) {
refreshFingerDriverStatus(defaultDevice);
}
}
void CharaMangerWorker::refreshFingerDriverStatus(const QString &defaultDevice)
{
bool isFingerValid = !defaultDevice.isEmpty();
m_model->setFingerValid(isFingerValid); // 修正拼写错误
if (isFingerValid) {
struct passwd *pws = getpwuid(getuid());
if (pws == nullptr) {
qWarning() << "Failed to get user information";
return;
}
refreshFingerEnrollList(pws->pw_name); // 直接使用 char*,避免不必要的转换
} else {
m_model->setThumbsList(QStringList());
}
}
这些改进将提高代码的安全性、性能和可维护性。 |
|
TAG Bot New tag: 6.1.47 |
|
TAG Bot New tag: 6.1.48 |
|
TAG Bot New tag: 6.1.49 |
|
TAG Bot New tag: 6.1.50 |
|
TAG Bot New tag: 6.1.51 |
|
TAG Bot New tag: 6.1.52 |
Fix the biometric authentication refresh not being timely.
Log: Fix the biometric authentication refresh not being timely.
pms: BUG-332419
Summary by Sourcery
Improve biometric authentication refresh to update driver status and fingerprint enrollment list immediately.
Bug Fixes: