Parcourir la source

modified compare functions (checks length of value)

master
kidjung il y a 4 ans
Parent
révision
44e6e5141f
1 fichiers modifiés avec 8 ajouts et 0 suppressions
  1. 8
    0
      src/broker/modules/secure.go

+ 8
- 0
src/broker/modules/secure.go Voir le fichier

@@ -59,6 +59,10 @@ func (sc Security) ReEncrypt(fromKey int64, toKey int64, target []int64) []int64
59 59
 Compare 함수들은 같으면 0 다르면 -1 (비교가 필요한 경우 오름차순 1 내림차순 -1)
60 60
 */
61 61
 func (sc Security) CompareTopic(topic1 []int64, topic2 []int64) int {
62
+	// 길이 같은지 체크
63
+	if len(topic1) != len(topic2) {
64
+		return -1
65
+	}
62 66
 	for i := 0; i < len(topic2); i++ {
63 67
 		if topic1[i] != topic2[i] {
64 68
 			return -1
@@ -77,6 +81,10 @@ func (sc Security) CompareDigit(topic1 int64, topic2 int64) int {
77 81
 }
78 82
 
79 83
 func (sc Security) CompareAlpha(topic1 []int64, topic2 []int64) int {
84
+	// 길이 같은지 체크
85
+	if len(topic1) != len(topic2) {
86
+		return -1
87
+	}
80 88
 	for i := 0; i < len(topic2); i++ {
81 89
 		if topic1[i] != topic2[i] {
82 90
 			return -1

Chargement…
Annuler
Enregistrer