Skip to content

Commit a849925

Browse files
authored
Add null check for ApiKeyPair in getUserByApiKey
The function getUserByApiKey was not checking for null pointers. I think this is safe from the perspective of security, but this is a smell. And it can be easily addressed with the same solution used in line 3160.
1 parent b6b5bfd commit a849925

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

server/src/main/java/com/cloud/user/AccountManagerImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3828,6 +3828,9 @@ public void buildACLViewSearchCriteria(SearchCriteria<? extends ControlledViewEn
38283828
@Override
38293829
public UserAccount getUserByApiKey(String apiKey) {
38303830
ApiKeyPairVO keyPair = apiKeyPairDao.findByApiKey(apiKey);
3831+
if (keyPair == null) {
3832+
return null;
3833+
}
38313834
return userAccountDao.findById(keyPair.getUserId());
38323835
}
38333836

0 commit comments

Comments
 (0)