drill-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vvysotskyi <...@git.apache.org>
Subject [GitHub] drill pull request #570: DRILL-4834 decimal implementation is vulnerable to ...
Date Tue, 09 Jan 2018 18:52:02 GMT
Github user vvysotskyi commented on a diff in the pull request:

    https://github.com/apache/drill/pull/570#discussion_r160458242
  
    --- Diff: exec/java-exec/src/main/codegen/templates/Decimal/CastDecimalVarchar.java ---
    @@ -150,6 +150,14 @@ public void setup() {
     
         public void eval() {
     
    +<#if type.from.contains("VarDecimal")>
    +        java.math.BigDecimal bigDecimal = org.apache.drill.exec.util.DecimalUtility.getBigDecimalFromDrillBuf(in.buffer,
in.start, in.end - in.start, in.scale);
    +        String str = bigDecimal.toString();
    +        out.buffer = buffer;
    +        out.start = 0;
    +        out.end = Math.min((int)len.value, str.length());
    +        out.buffer.setBytes(0, str.getBytes());
    --- End diff --
    
    What about the case when `str` has a length greater than `len`? I think it would be better
to use `setBytes(int index, byte[] src, int srcIndex, int length)` method here.


---

Mime
View raw message