pidgin: 371ba5a5: Fix two sizeof(size_t) != sizeof(unsigne...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Tue May 19 02:50:21 EDT 2009
-----------------------------------------------------------------
Revision: 371ba5a5719cb1bfa446344cb6b5abdae7c35377
Ancestor: 421c57c74fc62adb44a28e4b07943a33c5440a2c
Author: darkrain42 at pidgin.im
Date: 2009-05-19T06:40:04
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/371ba5a5719cb1bfa446344cb6b5abdae7c35377
Modified files:
libpurple/protocols/jabber/si.c
ChangeLog:
Fix two sizeof(size_t) != sizeof(unsigned int) warnings which could never
actually be problematic. I also documented the maximum sizes of the reads
at those lines.
-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/si.c 962db2ff1d58422fbf5a457e3acea9ba29f99da8
+++ libpurple/protocols/jabber/si.c 77557b14d604e0cf955c650f81a71e301c2be92b
@@ -441,9 +441,11 @@ jabber_si_xfer_bytestreams_send_read_aga
purple_xfer_cancel_remote(xfer);
return;
} else if(jsx->rxlen - 5 < jsx->rxqueue[4] + 2) {
- purple_debug_info("jabber", "reading %u bytes for DST.ADDR + port num (trying to read %u now)\n",
- jsx->rxqueue[4] + 2, jsx->rxqueue[4] + 2 - (jsx->rxlen - 5));
- len = read(source, buffer, jsx->rxqueue[4] + 2 - (jsx->rxlen - 5));
+ /* Upper-bound of 257 (jsx->rxlen = 5, jsx->rxqueue[4] = 0xFF) */
+ unsigned short to_read = jsx->rxqueue[4] + 2 - (jsx->rxlen - 5);
+ purple_debug_info("jabber", "reading %u bytes for DST.ADDR + port num (trying to read %hu now)\n",
+ jsx->rxqueue[4] + 2, to_read);
+ len = read(source, buffer, to_read);
if(len < 0 && errno == EAGAIN)
return;
else if(len <= 0) {
@@ -586,10 +588,12 @@ jabber_si_xfer_bytestreams_send_read_cb(
memcpy(jsx->rxqueue + jsx->rxlen, buffer, len);
jsx->rxlen += len;
return;
- } else if(jsx->rxlen - 2 < jsx->rxqueue[1]) {
- purple_debug_info("jabber", "reading %u bytes for auth methods (trying to read %u now)\n",
- jsx->rxqueue[1], jsx->rxqueue[1] - (jsx->rxlen - 2));
- len = read(source, buffer, jsx->rxqueue[1] - (jsx->rxlen - 2));
+ } else if(jsx->rxlen - 2 < jsx->rxqueue[1]) {
+ /* Has a maximum value of 255 (jsx->rxlen = 2, jsx->rxqueue[1] = 0xFF) */
+ unsigned short to_read = jsx->rxqueue[1] - (jsx->rxlen - 2);
+ purple_debug_info("jabber", "reading %u bytes for auth methods (trying to read %hu now)\n",
+ jsx->rxqueue[1], to_read);
+ len = read(source, buffer, to_read);
if(len < 0 && errno == EAGAIN)
return;
else if(len <= 0) {
More information about the Commits
mailing list