Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/odbc/odbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -3168,7 +3168,7 @@ odbc_unquote(char *buf, size_t buf_len, const char *start, const char *end)
/* not quoted */
if (*start != '[' && *start != '\"') {
--buf_len;
if (end - start < buf_len)
if (end < start + buf_len)
buf_len = end - start;
memcpy(buf, start, buf_len);
buf[buf_len] = 0;
Expand Down Expand Up @@ -7532,7 +7532,7 @@ odbc_stat_execute(TDS_STMT * stmt _WIDE, const char *begin, int nparams, ...)
strcpy(p, begin);
p += strlen(begin);
tds_dstr_setlen(&stmt->query, p - proc);
assert(p - proc + 1 <= len);
assert(p + 1 <= proc + len);

/* execute it */
retcode = _SQLExecute(stmt);
Expand Down
4 changes: 2 additions & 2 deletions src/odbc/odbc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ odbc_iso2utf(DSTR *res, const char *s, unsigned int len)
*p++ = u;
}
}
assert(p+1-out <= o_len);
assert(p + 1 <= out + o_len);
return tds_dstr_setlen(res, p - out);
}

Expand Down Expand Up @@ -211,7 +211,7 @@ odbc_wide2utf(DSTR *res, const SQLWCHAR *s, unsigned int len)
}
*p++ = 0x80 | (0x3f & u);
}
assert(p+1-out <= o_len);
assert(p + 1 <= out + o_len);
return tds_dstr_setlen(res, p - out);
}

Expand Down
4 changes: 2 additions & 2 deletions src/tds/unittests/freeze.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ strip_headers(buffer *buf)
assert(end - p >= 8); /* to read SMP part */
len = TDS_GET_UA4LE(p+4);
assert(len >= 16);
assert(end - p >= len);
assert(p + len <= end);
p += 16;
len -= 16;
assert(end - p >= 4); /* to read TDS header part */
Expand All @@ -138,7 +138,7 @@ strip_headers(buffer *buf)
len = TDS_GET_UA2BE(p+2);
}
assert(len > 8);
assert(end - p >= len);
assert(p + len <= end);
final = p[1];
memmove(dst, p + 8, len - 8);
dst += len - 8;
Expand Down