Instead, do this:

    public static int getCharUnpaddedLength(byte[] b, int offset, int length, ColumnModifier cMod) {
        int i = offset + length - 1;
        // If bytes are inverted, we need to invert the byte we're looking for too
        byte padByte = cMod == null ? 0 : cMod.apply(0);
        while(b[i] == padByte && i-- > offset) {}
        // Return modified length (no need to copy buffer)
        return i - offset + 1;
    }