mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-19 14:27:58 +08:00
int overflow
This commit is contained in:
@@ -2,6 +2,7 @@ package engine
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"
|
"github.com/seaweedfs/seaweedfs/weed/pb/schema_pb"
|
||||||
@@ -265,14 +266,14 @@ func (e *SQLEngine) Left(value *schema_pb.Value, length *schema_pb.Value) (*sche
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if int(lengthVal) >= len(str) {
|
if lengthVal > int64(len(str)) || lengthVal > int64(math.MaxInt) {
|
||||||
return &schema_pb.Value{
|
return &schema_pb.Value{
|
||||||
Kind: &schema_pb.Value_StringValue{StringValue: str},
|
Kind: &schema_pb.Value_StringValue{StringValue: str},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return &schema_pb.Value{
|
return &schema_pb.Value{
|
||||||
Kind: &schema_pb.Value_StringValue{StringValue: str[:lengthVal]},
|
Kind: &schema_pb.Value_StringValue{StringValue: str[:int(lengthVal)]},
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -298,7 +299,7 @@ func (e *SQLEngine) Right(value *schema_pb.Value, length *schema_pb.Value) (*sch
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if int(lengthVal) >= len(str) {
|
if lengthVal > int64(len(str)) || lengthVal > int64(math.MaxInt) {
|
||||||
return &schema_pb.Value{
|
return &schema_pb.Value{
|
||||||
Kind: &schema_pb.Value_StringValue{StringValue: str},
|
Kind: &schema_pb.Value_StringValue{StringValue: str},
|
||||||
}, nil
|
}, nil
|
||||||
|
Reference in New Issue
Block a user