Skip to content

Commit 2c913a8

Browse files
committed
Fixed comparison vulnerability
1 parent a69f640 commit 2c913a8

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/document/HibernateVersionDAO.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import java.util.Date;
77
import java.util.HashSet;
88
import java.util.List;
9+
import java.util.Map;
910
import java.util.Set;
1011

1112
import javax.annotation.Resource;
@@ -50,8 +51,8 @@ public List<Version> findByDocId(long docId) throws PersistenceException {
5051

5152
@Override
5253
public Version findByVersion(long docId, String version) throws PersistenceException {
53-
List<Version> versions = findByWhere(
54-
" " + ENTITY + DOC_ID + docId + " and " + ENTITY + ".version='" + version + "'", null, null);
54+
List<Version> versions = findByWhere(" " + ENTITY + DOC_ID + docId + " and " + ENTITY + ".version = :version",
55+
Map.of("version", version), null, null);
5556

5657
if (!versions.isEmpty())
5758
return versions.get(0);
@@ -62,8 +63,8 @@ public Version findByVersion(long docId, String version) throws PersistenceExcep
6263
@Override
6364
public Version findByFileVersion(long docId, String fileVersion) throws PersistenceException {
6465
List<Version> versions = findByWhere(
65-
" " + ENTITY + DOC_ID + docId + " and " + ENTITY + ".fileVersion='" + fileVersion + "'",
66-
ENTITY + ".date asc", null);
66+
" " + ENTITY + DOC_ID + docId + " and " + ENTITY + ".fileVersion = :fileVersion",
67+
Map.of("fileVersion", fileVersion), ENTITY + ".date asc", null);
6768

6869
if (!versions.isEmpty())
6970
return versions.get(0);

0 commit comments

Comments
 (0)