Skip to content

Commit ceaf62b

Browse files
committed
Make sure strings in old login structure have correct size
Old strings inside login packet have a structure with a single byte as size at the end, make sure the length can fit into a single byte. Signed-off-by: Frediano Ziglio <[email protected]>
1 parent 962aae0 commit ceaf62b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/tds/login.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,18 @@ tds_connect_and_login(TDSSOCKET * tds, TDSLOGIN * login)
757757
return tds_connect(tds, login, &oserr);
758758
}
759759

760-
static int
760+
static void
761761
tds_put_login_string(TDSSOCKET * tds, const char *buf, int n)
762762
{
763763
const int buf_len = buf ? (int)strlen(buf) : 0;
764-
return tds_put_buf(tds, (const unsigned char *) buf, n, buf_len);
764+
tds_put_buf(tds, (const unsigned char *) buf, n, buf_len);
765765
}
766766

767+
#define tds_put_login_string(tds, buf, n) do { \
768+
TDS_COMPILE_CHECK(range, (n) > 0 && (n) < 256); \
769+
tds_put_login_string(tds, buf, (n)); \
770+
} while(0)
771+
767772
static TDSRET
768773
tds_send_login(TDSSOCKET * tds, const TDSLOGIN * login)
769774
{

0 commit comments

Comments
 (0)