|
|
@@ -199,22 +199,6 @@ func (dt *dynamicTable) evict() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// constantTimeStringCompare compares string a and b in a constant
|
|
|
-// time manner.
|
|
|
-func constantTimeStringCompare(a, b string) bool {
|
|
|
- if len(a) != len(b) {
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- c := byte(0)
|
|
|
-
|
|
|
- for i := 0; i < len(a); i++ {
|
|
|
- c |= a[i] ^ b[i]
|
|
|
- }
|
|
|
-
|
|
|
- return c == 0
|
|
|
-}
|
|
|
-
|
|
|
// Search searches f in the table. The return value i is 0 if there is
|
|
|
// no name match. If there is name match or name/value match, i is the
|
|
|
// index of that entry (1-based). If both name and value match,
|
|
|
@@ -223,7 +207,7 @@ func (dt *dynamicTable) search(f HeaderField) (i uint64, nameValueMatch bool) {
|
|
|
l := len(dt.ents)
|
|
|
for j := l - 1; j >= 0; j-- {
|
|
|
ent := dt.ents[j]
|
|
|
- if !constantTimeStringCompare(ent.Name, f.Name) {
|
|
|
+ if ent.Name != f.Name {
|
|
|
continue
|
|
|
}
|
|
|
if i == 0 {
|
|
|
@@ -232,14 +216,12 @@ func (dt *dynamicTable) search(f HeaderField) (i uint64, nameValueMatch bool) {
|
|
|
if f.Sensitive {
|
|
|
continue
|
|
|
}
|
|
|
- if !constantTimeStringCompare(ent.Value, f.Value) {
|
|
|
+ if ent.Value != f.Value {
|
|
|
continue
|
|
|
}
|
|
|
- i = uint64(l - j)
|
|
|
- nameValueMatch = true
|
|
|
- return
|
|
|
+ return uint64(l - j), true
|
|
|
}
|
|
|
- return
|
|
|
+ return i, false
|
|
|
}
|
|
|
|
|
|
func (d *Decoder) maxTableIndex() int {
|