--- a/libpurple/protocols/gg/lib/dcc.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/dcc.c Mon Mar 24 20:01:11 2014 -0400
@@ -138,19 +138,24 @@
- if (stat(local_filename, &st) == -1) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() stat() failed (%s)\n", strerror(errno));
+ if ((d->file_fd = open(local_filename, O_RDONLY)) == -1) { + gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() open() failed (%s)\n", strerror(errno)); + if (fstat(d->file_fd, &st) == -1) { + gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() " + "fstat() failed (%s)\n", strerror(errno)); if ((st.st_mode & S_IFDIR)) {
gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() that's a directory\n");
- if ((d->file_fd = open(local_filename, O_RDONLY)) == -1) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() open() failed (%s)\n", strerror(errno));
@@ -209,7 +214,8 @@
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() short name \"%s\", dos name \"%s\"\n", name, d->file_info.short_filename);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_fill_file_info2() short name \"%s\"," + " dos name \"%s\"\n", name, d->file_info.short_filename); strncpy((char*) d->file_info.filename, name, sizeof(d->file_info.filename) - 1);
@@ -233,7 +239,9 @@
- gg_debug(GG_DEBUG_FUNCTION, "** gg_dcc_transfer(%s, %d, %ld, %ld, %s);\n", inet_ntoa(addr), port, my_uin, peer_uin, (type == GG_SESSION_DCC_SEND) ? "SEND" : "GET");
+ gg_debug(GG_DEBUG_FUNCTION, "** gg_dcc_transfer(%s, %d, %u, %u, " + "%s);\n", inet_ntoa(addr), port, my_uin, peer_uin, + (type == GG_SESSION_DCC_SEND) ? "SEND" : "GET"); if (!ip || ip == INADDR_NONE || !port || !my_uin || !peer_uin) {
gg_debug(GG_DEBUG_MISC, "// gg_dcc_transfer() invalid arguments\n");
@@ -504,11 +512,15 @@
if (_tmp < (int) size) { \
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed (errno=%d, %s)\n", errno, strerror(errno)); \
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed " \ + "(errno=%d, %s)\n", errno, strerror(errno)); \ } else if (_tmp == 0) { \
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed, connection broken\n"); \
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed, " \ + "connection broken\n"); \ - gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed (%d bytes, %d needed)\n", _tmp, size); \
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed " \ + "(%d bytes, %" GG_SIZE_FMT " needed)\n", \ e->type = GG_EVENT_DCC_ERROR; \
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE; \
@@ -531,9 +543,12 @@
write_res = send(fd, buf, size, 0); \
if (write_res < (int) size) { \
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() send() failed (errno=%d, %s)\n", errno, strerror(errno)); \
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() send() " \ + "failed (errno=%d, %s)\n", errno, strerror(errno)); \ - gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() send() failed (%d needed, %d done)\n", size, write_res); \
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() send() " \ + "failed (%" GG_SIZE_FMT " needed, %d done)\n", \ e->type = GG_EVENT_DCC_ERROR; \
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE; \
@@ -561,7 +576,12 @@
gg_debug(GG_DEBUG_FUNCTION, "** gg_dcc_watch_fd(%p);\n", h);
- if (!h || (h->type != GG_SESSION_DCC && h->type != GG_SESSION_DCC_SOCKET && h->type != GG_SESSION_DCC_SEND && h->type != GG_SESSION_DCC_GET && h->type != GG_SESSION_DCC_VOICE)) {
+ if (!h || (h->type != GG_SESSION_DCC && + h->type != GG_SESSION_DCC_SOCKET && + h->type != GG_SESSION_DCC_SEND && + h->type != GG_SESSION_DCC_GET && + h->type != GG_SESSION_DCC_VOICE)) gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() invalid argument\n");
@@ -578,24 +598,23 @@
socklen_t sin_len = sizeof(sin);
if ((fd = accept(h->fd, (struct sockaddr*) &sin, &sin_len)) == -1) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() can't accept() new connection (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() can't " + "accept() new connection (errno=%d, %s)\n", + errno, strerror(errno)); - gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() new direct connection from %s:%d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port));
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() new direct " + "connection from %s:%d\n", inet_ntoa(sin.sin_addr),
- if (ioctl(fd, FIONBIO, &one) == -1) {
- if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() can't set nonblocking (errno=%d, %s)\n", errno, strerror(errno));
+ if (!gg_fd_set_nonblocking(fd)) { + gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() can't set" + " nonblocking (errno=%d, %s)\n", + errno, strerror(errno)); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE;
@@ -644,7 +663,9 @@
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() GG_READING_UIN_%d\n", (h->state == GG_STATE_READING_UIN_1) ? 1 : 2);
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() GG_READING_UIN_%d\n", + (h->state == GG_STATE_READING_UIN_1) ? 1 : 2); gg_dcc_read(h->fd, &uin, sizeof(uin));
@@ -667,7 +688,7 @@
case GG_STATE_SENDING_ACK:
gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() GG_SENDING_ACK\n");
- gg_dcc_write(h->fd, ack, 4);
+ gg_dcc_write(h->fd, ack, (size_t)4); h->state = GG_STATE_READING_TYPE;
h->check = GG_CHECK_READ;
@@ -705,7 +726,8 @@
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() unknown dcc type (%.4x) from %ld\n", small_pkt.type, h->peer_uin);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() unknown dcc type " + "(%.4x) from %u\n", small_pkt.type, h->peer_uin); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE;
@@ -738,7 +760,9 @@
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() unknown dcc request (%.4x) from %ld\n", small_pkt.type, h->peer_uin);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() unknown " + "dcc request (%.4x) from %u\n", + small_pkt.type, h->peer_uin); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE;
@@ -806,13 +830,16 @@
tmp = recv(h->fd, h->chunk_buf + h->chunk_offset, h->chunk_size - h->chunk_offset, 0);
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() " + "failed (errno=%d, %s)\n", errno, strerror(errno)); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
- gg_dcc_debug_data("read", h->fd, h->chunk_buf + h->chunk_offset, h->chunk_size - h->chunk_offset);
+ gg_dcc_debug_data("read", h->fd, + h->chunk_buf + h->chunk_offset, + h->chunk_size - h->chunk_offset); @@ -860,10 +887,12 @@
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() peer breaking connection\n");
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "peer breaking connection\n"); /* XXX zwracać odpowiedni event */
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() unknown request (%.2x)\n", tiny_pkt.type);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "unknown request (%.2x)\n", tiny_pkt.type); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE;
@@ -878,7 +907,8 @@
small_pkt.type = gg_fix32(small_pkt.type);
if (small_pkt.type < 16 || small_pkt.type > sizeof(buf)) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() invalid voice frame size (%d)\n", small_pkt.type);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "invalid voice frame size (%d)\n", small_pkt.type); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
@@ -906,9 +936,12 @@
tmp = recv(h->fd, h->voice_buf + h->chunk_offset, h->chunk_size - h->chunk_offset, 0);
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "recv() failed (errno=%d, %s)\n", + errno, strerror(errno)); - gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed, connection broken\n");
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "recv() failed, connection broken\n"); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
@@ -940,7 +973,10 @@
if ((foo = getsockopt(h->fd, SOL_SOCKET, SO_ERROR, &res, &res_size)) || res) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() connection failed (fd=%d,errno=%d(%s),foo=%d,res=%d(%s))\n", h->fd, errno, strerror(errno), foo, res, strerror(res));
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() connection failed " + "(fd=%d,errno=%d(%s),foo=%d,res=%d(%s))\n", + h->fd, errno, strerror(errno), foo, res, strerror(res)); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_HANDSHAKE;
@@ -963,7 +999,7 @@
case GG_STATE_READING_ACK:
gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() GG_STATE_READING_ACK\n");
- gg_dcc_read(h->fd, buf, 4);
+ gg_dcc_read(h->fd, buf, (size_t)4); if (strncmp(buf, ack, 4)) {
gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() did't get ack\n");
@@ -995,7 +1031,8 @@
case GG_STATE_SENDING_REQUEST:
gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() GG_STATE_SENDING_REQUEST\n");
- small_pkt.type = (h->type == GG_SESSION_DCC_GET) ? gg_fix32(0x0003) : gg_fix32(0x0002); /* XXX */
+ small_pkt.type = (h->type == GG_SESSION_DCC_GET) ? + gg_fix32(0x0003) : gg_fix32(0x0002); /* XXX */ gg_dcc_write(h->fd, &small_pkt, sizeof(small_pkt));
@@ -1076,7 +1113,9 @@
gg_dcc_read(h->fd, &tiny_pkt, sizeof(tiny_pkt));
if (tiny_pkt.type != 0x01) {
- gg_debug(GG_DEBUG_MISC, "// invalid reply (%.2x), connection refused\n", tiny_pkt.type);
+ gg_debug(GG_DEBUG_MISC, "// invalid " + "reply (%.2x), connection " + "refused\n", tiny_pkt.type); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_REFUSED;
@@ -1119,11 +1158,15 @@
if ((utmp = h->chunk_size - h->chunk_offset) > sizeof(buf))
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() offset=%d, size=%d\n", h->offset, h->file_info.size);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "offset=%d, size=%d\n", + h->offset, h->file_info.size); if (h->file_info.size == 0) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() read() reached eof on empty file\n");
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() read()" + "reached eof on empty file\n"); e->type = GG_EVENT_DCC_DONE;
@@ -1135,13 +1178,26 @@
- lseek(h->file_fd, h->offset, SEEK_SET);
+ if (lseek(h->file_fd, h->offset, SEEK_SET) != (off_t)h->offset) { + gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() lseek() " + "failed. (errno=%d, %s)\n", + errno, strerror(errno)); + e->type = GG_EVENT_DCC_ERROR; + e->event.dcc_error = GG_ERROR_DCC_FILE; size = read(h->file_fd, buf, utmp);
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() read() failed. (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() read() " + "failed. (errno=%d, %s)\n", + errno, strerror(errno)); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_FILE;
@@ -1160,11 +1216,17 @@
/* jeśli wczytaliśmy więcej, utnijmy. */
if (h->offset + size > h->file_info.size) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() read() too much (read=%d, ofs=%d, size=%d)\n", size, h->offset, h->file_info.size);
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() read() " + "too much (read=%d, ofs=%d, " + "size=%d)\n", size, h->offset, size = h->file_info.size - h->offset;
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() reached EOF after cutting\n");
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() " + "reached EOF after cutting\n"); e->type = GG_EVENT_DCC_DONE;
@@ -1173,14 +1235,18 @@
tmp = send(h->fd, buf, size, 0);
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() send() failed (%s)\n", strerror(errno));
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() send() " + "failed (%s)\n", strerror(errno)); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() send() failed (connection reset)\n");
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() send() " + "failed (connection reset)\n"); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
@@ -1222,11 +1288,16 @@
size = recv(h->fd, buf, utmp, 0);
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() ofs=%d, size=%d, recv()=%d\n", h->offset, h->file_info.size, size);
+ gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() " + "ofs=%d, size=%d, recv()=%d\n", + h->offset, h->file_info.size, size); - gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() recv() failed. (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() recv() " + "failed. (errno=%d, %s)\n", + errno, strerror(errno)); e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
@@ -1246,7 +1317,11 @@
tmp = write(h->file_fd, buf, size);
if (tmp == -1 || tmp < size) {
- gg_debug(GG_DEBUG_MISC, "// gg_dcc_watch_fd() write() failed (%d:fd=%d:res=%d:%s)\n", tmp, h->file_fd, size, strerror(errno));
+ gg_debug(GG_DEBUG_MISC, + "// gg_dcc_watch_fd() write() " + "failed (%d:fd=%d:res=%d:%s)\n", e->type = GG_EVENT_DCC_ERROR;
e->event.dcc_error = GG_ERROR_DCC_NET;
--- a/libpurple/protocols/gg/lib/dcc7.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/dcc7.c Mon Mar 24 20:01:11 2014 -0400
@@ -5,7 +5,7 @@
* Tomasz Chiliński <chilek@chilan.com>
* Adam Wysocki <gophi@ekg.chmurka.net>
* Bartłomiej Zimoń <uzi18@o2.pl>
* Thanks to Jakub Zawadzki <darkjames@darkjames.ath.cx>
* This program is free software; you can redistribute it and/or modify
@@ -167,7 +167,9 @@
if (dcc->sess->resolver_start(&dcc->fd, &dcc->resolver, GG_RELAY_HOST) == -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_get_relay_addr() resolving failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_get_relay_addr() " + "resolving failed (errno=%d, %s)\n", + errno, strerror(errno)); @@ -243,7 +245,8 @@
sin.sin_port = htons(port);
if (bind(fd, (struct sockaddr*) &sin, sizeof(sin)) == -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() unable to bind to %s:%d\n", inet_ntoa(sin.sin_addr), port);
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_listen() unable to" + " bind to %s:%d\n", inet_ntoa(sin.sin_addr), port); @@ -260,7 +263,7 @@
dcc->local_addr = sin.sin_addr.s_addr;
dcc->local_port = ntohs(sin.sin_port);
dcc->state = GG_STATE_LISTENING;
dcc->check = GG_CHECK_READ;
dcc->timeout = GG_DCC7_TIMEOUT_FILE_ACK;
@@ -292,7 +295,7 @@
if (gg_dcc7_listen(dcc, dcc->sess->client_addr, dcc->sess->client_port) == -1)
if (dcc->sess->external_port != 0)
external_port = dcc->sess->external_port;
@@ -300,12 +303,14 @@
if (dcc->sess->external_addr != 0)
external_addr = dcc->sess->external_addr;
external_addr = dcc->local_addr;
addr.s_addr = external_addr;
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// dcc7_listen_and_send_info() sending IP address %s and port %d\n", inet_ntoa(addr), external_port);
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// dcc7_listen_and_send_info() " + "sending IP address %s and port %d\n", + inet_ntoa(addr), external_port); memset(&pkt, 0, sizeof(pkt));
pkt.uin = gg_fix32(dcc->peer_uin);
@@ -372,7 +377,7 @@
memset(&pkt, 0, sizeof(pkt));
pkt.type = gg_fix32(type);
@@ -397,7 +402,9 @@
-static struct gg_dcc7 *gg_dcc7_send_file_common(struct gg_session *sess, uin_t rcpt, int fd, size_t size, const char *filename1250, const char *hash, int seek)
+static struct gg_dcc7 *gg_dcc7_send_file_common(struct gg_session *sess, + uin_t rcpt, int fd, size_t size, const char *filename1250, + const char *hash, int seek) struct gg_dcc7 *dcc = NULL;
@@ -456,7 +463,8 @@
-struct gg_dcc7 *gg_dcc7_send_file(struct gg_session *sess, uin_t rcpt, const char *filename, const char *filename1250, const char *hash)
+struct gg_dcc7 *gg_dcc7_send_file(struct gg_session *sess, uin_t rcpt, + const char *filename, const char *filename1250, const char *hash) struct gg_dcc7 *dcc = NULL;
@@ -464,7 +472,8 @@
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_send_file(%p, %d, \"%s\", %p)\n", sess, rcpt, filename, hash);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_send_file(%p, %d," + " \"%s\", %p)\n", sess, rcpt, filename, hash); if (!sess || !rcpt || !filename) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() invalid parameters\n");
@@ -475,8 +484,14 @@
- if (stat(filename, &st) == -1) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() stat() failed (%s)\n", strerror(errno));
+ if ((fd = open(filename, O_RDONLY)) == -1) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() open() failed (%s)\n", strerror(errno)); + if (fstat(fd, &st) == -1) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() " + "fstat() failed (%s)\n", strerror(errno)); @@ -486,11 +501,6 @@
- if ((fd = open(filename, O_RDONLY)) == -1) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_send_file() open() failed (%s)\n", strerror(errno));
if (gg_file_hash_sha1(fd, (uint8_t*) hash_buf) == -1)
@@ -534,9 +544,12 @@
-struct gg_dcc7 *gg_dcc7_send_file_fd(struct gg_session *sess, uin_t rcpt, int fd, size_t size, const char *filename1250, const char *hash)
+struct gg_dcc7 *gg_dcc7_send_file_fd(struct gg_session *sess, uin_t rcpt, + int fd, size_t size, const char *filename1250, const char *hash) - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_send_file_fd(%p, %d, %d, %u, \"%s\", %p)\n", sess, rcpt, fd, size, filename1250, hash);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_send_file_fd(%p, " + "%d, %d, %" GG_SIZE_FMT ", \"%s\", %p)\n", + sess, rcpt, fd, size, filename1250, hash); return gg_dcc7_send_file_common(sess, rcpt, fd, size, filename1250, hash, 0);
@@ -629,11 +642,12 @@
gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_id(%p, %p, %p, %d)\n", sess, e, payload, len);
for (tmp = sess->dcc7_list; tmp; tmp = tmp->next) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// checking dcc %p, state %d, type %d\n", tmp, tmp->state, tmp->dcc_type);
+ gg_debug_session(sess, GG_DEBUG_MISC, "// checking dcc %p, " + "state %d, type %d\n", tmp, tmp->state, tmp->dcc_type); if (tmp->state != GG_STATE_REQUESTING_ID || tmp->dcc_type != (int) gg_fix32(p->type))
@@ -650,7 +664,10 @@
/* Uwaga: To nie jest ciąg kończony zerem.
* Note: This is not a null-terminated string. */
- strncpy((char*) s.filename, (char*) tmp->filename, sizeof(s.filename));
+ sizeof(s.filename) == sizeof(tmp->filename) - 1, + filename_sizes_does_not_match); + memcpy((char*)s.filename, (char*)tmp->filename, sizeof(s.filename)); tmp->state = GG_STATE_WAITING_FOR_ACCEPT;
tmp->timeout = GG_DCC7_TIMEOUT_FILE_ACK;
@@ -694,9 +711,9 @@
e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE;
/* XXX czy dla odwrotnego połączenia powinniśmy wywołać już zdarzenie GG_DCC7_ACCEPT? */
dcc->offset = gg_fix32(p->offset);
dcc->state = GG_STATE_WAITING_FOR_INFO;
@@ -720,13 +737,14 @@
gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_dcc7_handle_info(%p, %p, %p, %d)\n", sess, e, payload, len);
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "// gg_dcc7_handle_info() received address: %s, hash: %s\n", p->info, p->hash);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "// gg_dcc7_handle_info() " + "received address: %s, hash: %s\n", p->info, p->hash); if (!(dcc = gg_dcc7_session_find(sess, p->id, gg_fix32(p->uin)))) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unknown dcc session\n");
if (dcc->state == GG_STATE_CONNECTED) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() state is already connected\n");
@@ -750,7 +768,9 @@
if (dcc->state == GG_STATE_WAITING_FOR_INFO) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() waiting for info so send one\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_dcc7_handle_info() waiting for info " gg_dcc7_listen_and_send_info(dcc);
e->type = GG_EVENT_DCC7_PENDING;
e->event.dcc7_pending.dcc7 = dcc;
@@ -777,7 +797,10 @@
cid = strtoull(tmp + 2, NULL, 0);
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() info.str=%s, info.id=%llu, sess.id=%llu\n", tmp + 2, cid, *((unsigned long long*) &dcc->cid));
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_dcc7_handle_info() info.str=%s, " + "info.id=%llu, sess.id=%llu\n", tmp + 2, cid, + *((unsigned long long*) &dcc->cid)); @@ -788,6 +811,8 @@
if (gg_dcc7_get_relay_addr(dcc) == -1) {
@@ -804,7 +829,8 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() unhandled transfer type (%d)\n", p->type);
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info()" + " unhandled transfer type (%d)\n", p->type); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE;
@@ -814,12 +840,12 @@
/* jeśli nadal czekamy na połączenie przychodzące, a druga strona nie
* daje rady i oferuje namiary na siebie, bierzemy co dają.
- if (dcc->state != GG_STATE_WAITING_FOR_INFO && (dcc->state != GG_STATE_LISTENING || dcc->reverse)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid state\n");
- e->type = GG_EVENT_DCC7_ERROR;
- e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE;
+ if (dcc->state != GG_STATE_WAITING_FOR_INFO && (dcc->state != GG_STATE_LISTENING || dcc->reverse)) { + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_info() invalid state\n"); + e->type = GG_EVENT_DCC7_ERROR; + e->event.dcc7_error = GG_ERROR_DCC7_HANDSHAKE; if (dcc->state == GG_STATE_LISTENING) {
@@ -827,7 +853,7 @@
if (dcc->type == GG_SESSION_DCC7_SEND) {
e->type = GG_EVENT_DCC7_ACCEPT;
e->event.dcc7_accept.dcc7 = dcc;
@@ -871,7 +897,7 @@
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_reject() unknown dcc session\n");
if (dcc->state != GG_STATE_WAITING_FOR_ACCEPT) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_reject() invalid state\n");
e->type = GG_EVENT_DCC7_ERROR;
@@ -911,7 +937,7 @@
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() not enough memory\n");
memset(dcc, 0, sizeof(struct gg_dcc7));
dcc->type = GG_SESSION_DCC7_GET;
dcc->dcc_type = GG_DCC7_TYPE_FILE;
@@ -923,7 +949,9 @@
if (gg_dcc7_session_add(sess, dcc) == -1) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() unable to add to session\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_dcc7_handle_new() unable to " @@ -943,7 +971,7 @@
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_packet() not enough memory\n");
memset(dcc, 0, sizeof(struct gg_dcc7));
dcc->type = GG_SESSION_DCC7_VOICE;
@@ -956,7 +984,9 @@
if (gg_dcc7_session_add(sess, dcc) == -1) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() unable to add to session\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_dcc7_handle_new() unable to add " @@ -967,7 +997,10 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_dcc7_handle_new() unknown dcc type (%d) from %ld\n", gg_fix32(p->type), gg_fix32(p->uin_from));
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_dcc7_handle_new() unknown dcc type (%d) " + "from %u\n", gg_fix32(p->type), + gg_fix32(p->uin_from)); @@ -978,7 +1011,7 @@
* \internal Ustawia odpowiednie stany wewnętrzne w zależności od rodzaju
* \param dcc Struktura połączenia
* \return 0 jeśli się powiodło, -1 w przypadku błędu.
@@ -1034,7 +1067,10 @@
gg_debug_dcc(dcc, GG_DEBUG_FUNCTION, "** gg_dcc7_watch_fd(%p)\n", dcc);
- if (!dcc || (dcc->type != GG_SESSION_DCC7_SEND && dcc->type != GG_SESSION_DCC7_GET && dcc->type != GG_SESSION_DCC7_VOICE)) {
+ if (!dcc || (dcc->type != GG_SESSION_DCC7_SEND && + dcc->type != GG_SESSION_DCC7_GET && + dcc->type != GG_SESSION_DCC7_VOICE)) gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() invalid parameters\n");
@@ -1053,26 +1089,25 @@
socklen_t sin_len = sizeof(sin);
gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_LISTENING\n");
if ((fd = accept(dcc->fd, (struct sockaddr*) &sin, &sin_len)) == -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() accept() failed (%s)\n", strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() accept() failed " + "(%s)\n", strerror(errno)); - gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection from %s:%d\n", inet_ntoa(sin.sin_addr), htons(sin.sin_port));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd()" + " connection from %s:%d\n", + inet_ntoa(sin.sin_addr), htons(sin.sin_port));
- if (ioctl(fd, FIONBIO, &one) == -1) {
- if (fcntl(fd, F_SETFL, O_NONBLOCK) == -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() can't set nonblocking (%s)\n", strerror(errno));
+ if (!gg_fd_set_nonblocking(fd)) { + gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() can't set " + "nonblocking (%s)\n", strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE;
@@ -1108,11 +1143,20 @@
- if (error || (res = getsockopt(dcc->fd, SOL_SOCKET, SO_ERROR, &error, &error_size)) == -1 || error != 0) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection failed (%s)\n", (res == -1) ? strerror(errno) : strerror(error));
+ if (error || (res = getsockopt(dcc->fd, SOL_SOCKET, + SO_ERROR, &error, &error_size)) == -1 || + gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() connection " + "failed (%s)\n", (res == -1) ? + strerror(errno) : strerror(error)); - for (dcc->relay_index++; dcc->relay_index < dcc->relay_count; dcc->relay_index++) {
+ for (dcc->relay_index++; + dcc->relay_index < dcc->relay_count; dcc->remote_addr = dcc->relay_list[dcc->relay_index].addr;
dcc->remote_port = dcc->relay_list[dcc->relay_index].port;
@@ -1121,7 +1165,9 @@
if (dcc->relay_index >= dcc->relay_count) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() no relay available\n");
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() " + "no relay available\n"); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_RELAY;
@@ -1160,7 +1206,10 @@
welcome_ok.id = dcc->cid;
if ((res = recv(dcc->fd, &welcome, sizeof(welcome), 0)) != sizeof(welcome)) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() recv() failed (%d, %s)\n", res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() recv() " + "failed (%d, %s)\n", res, e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE;
@@ -1178,7 +1227,10 @@
welcome_ok.id = dcc->cid;
if ((res = recv(dcc->fd, &welcome, sizeof(welcome), 0)) != sizeof(welcome)) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() recv() failed (%d, %s)\n", res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() recv() " e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE;
@@ -1216,7 +1268,10 @@
if ((res = send(dcc->fd, &welcome, sizeof(welcome), 0)) != sizeof(welcome)) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() send() failed (%d, %s)\n", res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() send() " e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE;
@@ -1228,7 +1283,10 @@
if ((res = send(dcc->fd, &welcome, sizeof(welcome), 0)) != sizeof(welcome)) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() send() failed (%d, %s)\n", res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() send() " + "failed (%d, %s)\n", res, e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_HANDSHAKE;
@@ -1253,7 +1311,9 @@
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_SENDING_FILE (offset=%d, size=%d)\n", dcc->offset, dcc->size);
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd()" + " GG_STATE_SENDING_FILE (offset=%d, size=%d)\n", + dcc->offset, dcc->size); if (dcc->offset >= dcc->size) {
gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() offset >= size, finished\n");
@@ -1263,7 +1323,9 @@
if (dcc->seek && lseek(dcc->file_fd, dcc->offset, SEEK_SET) == (off_t) -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() lseek() failed (%s)\n", strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() lseek() failed " + "(%s)\n", strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_FILE;
@@ -1273,14 +1335,18 @@
if ((res = read(dcc->file_fd, buf, chunk)) < 1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() read() failed (res=%d, %s)\n", res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() read() failed " + "(res=%d, %s)\n", res, strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = (res == -1) ? GG_ERROR_DCC7_FILE : GG_ERROR_DCC7_EOF;
if ((res = send(dcc->fd, buf, res, 0)) == -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() send() failed (%s)\n", strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() send() failed " + "(%s)\n", strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_NET;
@@ -1307,7 +1373,9 @@
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_GETTING_FILE (offset=%d, size=%d)\n", dcc->offset, dcc->size);
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd()" + " GG_STATE_GETTING_FILE (offset=%d, size=%d)\n", + dcc->offset, dcc->size); if (dcc->offset >= dcc->size) {
gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() finished\n");
@@ -1317,7 +1385,10 @@
if ((res = recv(dcc->fd, buf, sizeof(buf), 0)) < 1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() recv() failed (fd=%d, res=%d, %s)\n", dcc->fd, res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() recv() failed " + "(fd=%d, res=%d, %s)\n", dcc->fd, res, e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = (res == -1) ? GG_ERROR_DCC7_NET : GG_ERROR_DCC7_EOF;
@@ -1326,7 +1397,10 @@
/* XXX zapisywać do skutku? */
if ((wres = write(dcc->file_fd, buf, res)) < res) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() write() failed (fd=%d, res=%d, %s)\n", dcc->file_fd, wres, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() write() failed " + "(fd=%d, res=%d, %s)\n", dcc->file_fd, + wres, strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_FILE;
@@ -1373,15 +1447,20 @@
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() resolved, connecting to %s:%d\n", inet_ntoa(addr), GG_RELAY_PORT);
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd()" + " resolved, connecting to %s:%d\n", + inet_ntoa(addr), GG_RELAY_PORT); if ((dcc->fd = gg_connect(&addr, GG_RELAY_PORT, 1)) == -1) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection failed (errno=%d, %s), critical\n", errno, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() connection " + "failed (errno=%d, %s), critical\n", + errno, strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_RELAY;
dcc->state = GG_STATE_CONNECTING_RELAY;
dcc->check = GG_CHECK_WRITE;
dcc->timeout = GG_DEFAULT_TIMEOUT;
@@ -1399,9 +1478,12 @@
struct gg_dcc7_relay_req pkt;
gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() GG_STATE_CONNECTING_RELAY\n");
if (getsockopt(dcc->fd, SOL_SOCKET, SO_ERROR, &res, &res_size) != 0 || res != 0) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() connection failed (errno=%d, %s)\n", res, strerror(res));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() connection " + "failed (errno=%d, %s)\n", e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_RELAY;
@@ -1414,7 +1496,8 @@
pkt.type = gg_fix16(GG_DCC7_RELAY_TYPE_SERVER);
pkt.dunno1 = gg_fix16(GG_DCC7_RELAY_DUNNO1);
- gg_debug_dcc(dcc, GG_DEBUG_DUMP, "// gg_dcc7_watch_fd() send pkt(0x%.2x)\n", gg_fix32(pkt.magic));
+ gg_debug_dcc(dcc, GG_DEBUG_DUMP, "// gg_dcc7_watch_fd()" + " send pkt(0x%.2x)\n", gg_fix32(pkt.magic)); gg_debug_dump_dcc(dcc, GG_DEBUG_DUMP, (const char*) &pkt, sizeof(pkt));
if ((res = send(dcc->fd, &pkt, sizeof(pkt), 0)) != sizeof(pkt)) {
@@ -1436,6 +1519,7 @@
struct gg_dcc7_relay_reply *pkt;
struct gg_dcc7_relay_reply_server srv;
+ size_t max_relay_count = (sizeof(buf) - sizeof(*pkt)) / sizeof(srv); @@ -1444,7 +1528,9 @@
if ((res = recv(dcc->fd, buf, sizeof(buf), 0)) < (int) sizeof(*pkt)) {
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_watch_fd() recv() failed (%d, %s)\n", res, strerror(errno));
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() recv() failed " + "(%d, %s)\n", res, strerror(errno)); e->type = GG_EVENT_DCC7_ERROR;
e->event.dcc_error = GG_ERROR_DCC7_RELAY;
@@ -1452,7 +1538,12 @@
pkt = (struct gg_dcc7_relay_reply*) buf;
- if (gg_fix32(pkt->magic) != GG_DCC7_RELAY_REPLY || gg_fix32(pkt->rcount) < 1 || gg_fix32(pkt->rcount > 256) || gg_fix32(pkt->len) < sizeof(*pkt) + gg_fix32(pkt->rcount) * sizeof(srv)) {
+ if (gg_fix32(pkt->magic) != GG_DCC7_RELAY_REPLY || + gg_fix32(pkt->rcount) < 1 || + gg_fix32(pkt->rcount > 256) || + gg_fix32(pkt->len) < sizeof(*pkt) + + gg_fix32(pkt->rcount) * sizeof(srv)) gg_debug_dcc(dcc, GG_DEBUG_MISC, "// gg_dcc7_wathc_fd() invalid reply\n");
e->type = GG_EVENT_DCC7_ERROR;
@@ -1460,13 +1551,27 @@
- gg_debug_dcc(dcc, GG_DEBUG_DUMP, "// gg_dcc7_get_relay() read pkt(0x%.2x)\n", gg_fix32(pkt->magic));
+ gg_debug_dcc(dcc, GG_DEBUG_DUMP, + "// gg_dcc7_get_relay() read pkt(0x%.2x)\n", gg_debug_dump_dcc(dcc, GG_DEBUG_DUMP, buf, res);
dcc->relay_count = gg_fix32(pkt->rcount);
+ if (dcc->relay_count > 0xffff || + (size_t)dcc->relay_count > max_relay_count) + gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// gg_dcc7_watch_fd() relay_count out " + "of bounds (%d)\n", dcc->relay_count); dcc->relay_list = malloc(dcc->relay_count * sizeof(gg_dcc7_relay_t));
if (dcc->relay_list == NULL) {
@@ -1485,9 +1590,11 @@
dcc->relay_list[i].family = srv.family;
- gg_debug_dcc(dcc, GG_DEBUG_MISC, "// %s %d %d\n", inet_ntoa(addr), gg_fix16(srv.port), srv.family);
+ gg_debug_dcc(dcc, GG_DEBUG_MISC, + "// %s %d %d\n", inet_ntoa(addr), + gg_fix16(srv.port), srv.family);
for (; dcc->relay_index < dcc->relay_count; dcc->relay_index++) {
@@ -1548,4 +1655,3 @@
--- a/libpurple/protocols/gg/lib/events.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/events.c Mon Mar 24 20:01:11 2014 -0400
@@ -156,7 +156,7 @@
case GG_EVENT_MULTILOGON_INFO:
@@ -259,7 +259,9 @@
#ifdef HAVE_GNUTLS_CERTIFICATE_SET_X509_SYSTEM_TRUST
gnutls_certificate_set_x509_system_trust(tmp->xcred);
- gnutls_certificate_set_x509_trust_file(tmp->xcred, GG_CONFIG_GNUTLS_SYSTEM_TRUST_STORE, GNUTLS_X509_FMT_PEM);
+ gnutls_certificate_set_x509_trust_file(tmp->xcred, + GG_CONFIG_GNUTLS_SYSTEM_TRUST_STORE, @@ -269,7 +271,7 @@
gnutls_init(&tmp->session, GNUTLS_CLIENT);
gnutls_set_default_priority(tmp->session);
gnutls_credentials_set(tmp->session, GNUTLS_CRD_CERTIFICATE, tmp->xcred);
- gnutls_transport_set_ptr(tmp->session, (gnutls_transport_ptr_t) (long) gs->fd);
+ gnutls_transport_set_ptr(tmp->session, (gnutls_transport_ptr_t) (intptr_t) gs->fd); #ifdef GG_CONFIG_HAVE_OPENSSL
@@ -336,19 +338,22 @@
if (sess->send_buf == NULL || sess->send_left == 0)
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() sending %d bytes of queued data\n", sess->send_left);
res = send(sess->fd, sess->send_buf, sess->send_left, 0);
if (errno == EAGAIN || errno == EINTR) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() non-critical send error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd()" + " non-critical send error (errno=%d, %s)\n", + errno, strerror(errno)); - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() send() failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() send() " + "failed (errno=%d, %s)\n", errno, strerror(errno)); @@ -359,7 +364,9 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() sent %d bytes of queued data, %d bytes left\n", res, sess->send_left - res);
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() sent %d" + " bytes of queued data, %d bytes left\n", + res, sess->send_left - res); memmove(sess->send_buf, sess->send_buf + res, sess->send_left - res);
@@ -409,7 +416,9 @@
-typedef gg_action_t (*gg_state_handler_t)(struct gg_session *gs, struct gg_event *ge, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state);
+typedef gg_action_t (*gg_state_handler_t)(struct gg_session *gs, + struct gg_event *ge, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state); @@ -496,7 +505,9 @@
-static gg_action_t gg_handle_resolve_sync(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_resolve_sync(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -508,13 +519,14 @@
addr.s_addr = inet_addr(sess->resolver_host);
if (addr.s_addr == INADDR_NONE) {
struct in_addr *addr_list = NULL;
if (gg_gethostbyname_real(sess->resolver_host, &addr_list, &addr_count, 0) == -1) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() host %s not found\n", sess->resolver_host);
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd()" + " host %s not found\n", sess->resolver_host); e->event.failure = GG_FAILURE_RESOLVING;
@@ -541,7 +553,9 @@
-static gg_action_t gg_handle_resolve_async(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_resolve_async(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -552,7 +566,9 @@
if (sess->resolver_start(&sess->fd, &sess->resolver, sess->resolver_host) == -1) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() resolving failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "resolving failed (errno=%d, %s)\n", + errno, strerror(errno)); e->event.failure = GG_FAILURE_RESOLVING;
@@ -564,7 +580,9 @@
-static gg_action_t gg_handle_resolving(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_resolving(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -574,14 +592,17 @@
res = gg_resolver_recv(sess->fd, buf, sizeof(buf));
if (res == -1 && (errno == EAGAIN || errno == EINTR)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() non-critical error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "non-critical error (errno=%d, %s)\n", + errno, strerror(errno)); sess->resolver_cleanup(&sess->resolver, 0);
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() read error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() read " + "error (errno=%d, %s)\n", errno, strerror(errno)); e->event.failure = GG_FAILURE_RESOLVING;
@@ -671,11 +692,13 @@
sess->resolver_index = 0;
-static gg_action_t gg_handle_connect(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_connect(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -689,6 +712,7 @@
addr = sess->resolver_result[sess->resolver_index];
if (sess->state == GG_STATE_CONNECT_HUB) {
+ sess->hub_addr = addr.s_addr; sess->proxy_addr = addr.s_addr;
@@ -700,7 +724,9 @@
sess->fd = gg_connect(&addr, port, sess->async);
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() connection failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "connection failed (errno=%d, %s)\n", + errno, strerror(errno)); @@ -713,14 +739,18 @@
-static gg_action_t gg_handle_connecting(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_connecting(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) if (gg_async_connect_failed(sess, &res)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() connection failed (errno=%d, %s)\n", res, strerror(res));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "connection failed (errno=%d, %s)\n", @@ -738,14 +768,22 @@
-static gg_action_t gg_handle_connect_gg(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_connect_gg(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) - gg_debug_session(sess, GG_DEBUG_MISC, "resolver_index=%d, connect_index=%d, connect_port={%d,%d}\n", sess->resolver_index, sess->connect_index, sess->connect_port[0], sess->connect_port[1]);
+ gg_debug_session(sess, GG_DEBUG_MISC, "resolver_index=%d, " + "connect_index=%d, connect_port={%d,%d}\n", + sess->resolver_index, sess->connect_index, + sess->connect_port[0], sess->connect_port[1]); - if ((unsigned int) sess->connect_index >= sizeof(sess->connect_port) / sizeof(sess->connect_port[0]) || sess->connect_port[sess->connect_index] == 0) {
+ if ((unsigned int) sess->connect_index >= + sizeof(sess->connect_port) / sizeof(sess->connect_port[0]) || + sess->connect_port[sess->connect_index] == 0) if (sess->resolver_index >= sess->resolver_count) {
@@ -764,7 +802,9 @@
sess->fd = gg_connect(&addr, port, sess->async);
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() connection failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "connection failed (errno=%d, %s)\n", + errno, strerror(errno)); @@ -777,7 +817,9 @@
-static gg_action_t gg_handle_connecting_gg(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_connecting_gg(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -785,7 +827,9 @@
/* jeśli wystąpił błąd podczas łączenia się... */
if (gg_async_connect_failed(sess, &res)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() connection failed (errno=%d, %s)\n", res, strerror(res));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "connection failed (errno=%d, %s)\n", @@ -817,7 +861,9 @@
-static gg_action_t gg_handle_send_hub(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_send_hub(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) char *req, *client, *auth;
@@ -849,7 +895,8 @@
if (sess->ssl_flag != GG_SSL_DISABLED) {
- ("GET %s/appsvc/appmsg_ver10.asp?fmnumber=%u&fmt=2&lastmsg=%d&version=%s&age=2&gender=1 HTTP/1.0\r\n"
+ ("GET %s/appsvc/appmsg_ver10.asp?fmnumber=%u&fmt=2&" + "lastmsg=%d&version=%s&age=2&gender=1 HTTP/1.0\r\n" "Host: " GG_APPMSG_HOST "\r\n"
@@ -862,6 +909,9 @@
"\r\n", host, sess->uin, sess->last_sysmsg, client, (auth) ? auth : "");
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() out of memory\n");
e->event.failure = GG_FAILURE_PROXY;
@@ -870,15 +920,12 @@
gg_debug_session(sess, GG_DEBUG_TRAFFIC, "// sending http query:\n%s", req);
res = send(sess->fd, req, req_len, 0);
if (res == -1 && errno != EINTR && errno != EAGAIN) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() sending query failed\n");
e->event.failure = (!proxy) ? GG_FAILURE_HUB : GG_FAILURE_PROXY;
@@ -898,7 +945,9 @@
-static gg_action_t gg_handle_sending_hub_proxy(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_sending_hub_proxy(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) if (gg_send_queued_data(sess) == -1) {
e->event.failure = GG_FAILURE_WRITING;
@@ -915,7 +964,9 @@
-static gg_action_t gg_handle_reading_hub_proxy(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_reading_hub_proxy(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) char buf[1024], *tmp, host[128];
int port = GG_DEFAULT_PORT;
@@ -929,12 +980,15 @@
res = recv(sess->fd, buf, sizeof(buf), 0);
if (res == -1 && (errno == EAGAIN || errno == EINTR)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() non-critical recv error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "non-critical recv error (errno=%d, %s)\n", + errno, strerror(errno)); - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() recv error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() recv " + "error (errno=%d, %s)\n", errno, strerror(errno)); e->event.failure = GG_FAILURE_CONNECTING;
@@ -975,7 +1029,7 @@
/* szukamy początku treści */
body = strstr(sess->recv_buf, "\r\n\r\n");
body = strstr(sess->recv_buf, "\n\n");
@@ -990,7 +1044,7 @@
- // 17591 0 91.197.13.71:8074 91.197.13.71
+ /* 17591 0 91.197.13.71:8074 91.197.13.71 */ res = sscanf(body, "%d %*d %128s", &reply, host);
@@ -1013,7 +1067,9 @@
e->event.msg.message = (unsigned char*) strdup(tmp + 1);
if (e->event.msg.message == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() not enough memory for system message\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_watch_fd() not enough memory " + "for system message\n"); @@ -1029,7 +1085,7 @@
if (strcmp(host, "notoperating") == 0) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() service unavailable\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() service unavailable\n"); e->event.failure = GG_FAILURE_UNAVAILABLE;
@@ -1120,7 +1176,9 @@
-static gg_action_t gg_handle_send_proxy_gg(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_send_proxy_gg(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -1136,7 +1194,9 @@
- req = gg_saprintf("CONNECT %s:%d HTTP/1.0\r\n%s\r\n", sess->connect_host, sess->connect_port[sess->connect_index], (auth) ? auth : "");
+ req = gg_saprintf("CONNECT %s:%d HTTP/1.0\r\n%s\r\n", + sess->connect_host, sess->connect_port[sess->connect_index], @@ -1175,9 +1235,13 @@
-static gg_action_t gg_handle_tls_negotiation(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_tls_negotiation(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) +#if defined(GG_CONFIG_HAVE_GNUTLS) || defined(GG_CONFIG_HAVE_OPENSSL) #ifdef GG_CONFIG_HAVE_GNUTLS
@@ -1205,7 +1269,9 @@
if (res != GNUTLS_E_SUCCESS) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() TLS handshake error: %d, %s\n", res, gnutls_strerror(res));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd()" + " TLS handshake error: %d, %s\n", + res, gnutls_strerror(res)); e->event.failure = GG_FAILURE_TLS;
@@ -1253,7 +1319,9 @@
res = gnutls_certificate_verify_peers2(GG_SESSION_GNUTLS(sess), &status);
if (res != 0 || status != 0) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// WARNING! unable to verify peer certificate: 0x%x, %d, %s\n", status, res, gnutls_strerror(res));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// WARNING! unable to" + " verify peer certificate: 0x%x, %d, %s\n", status, res, if (sess->ssl_flag == GG_SSL_REQUIRED) {
e->event.failure = GG_FAILURE_TLS;
@@ -1275,7 +1343,7 @@
err = SSL_get_error(GG_SESSION_OPENSSL(sess), res);
@@ -1308,7 +1376,9 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() TLS negotiation succeded:\n// cipher: %s\n", SSL_get_cipher_name(GG_SESSION_OPENSSL(sess)));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() TLS negotiation" + " succeded:\n// cipher: %s\n", + SSL_get_cipher_name(GG_SESSION_OPENSSL(sess))); peer = SSL_get_peer_certificate(GG_SESSION_OPENSSL(sess));
@@ -1332,7 +1402,9 @@
res = SSL_get_verify_result(GG_SESSION_OPENSSL(sess));
- gg_debug_session(sess, GG_DEBUG_MISC, "// WARNING! unable to verify peer certificate! res=%ld\n", res);
+ gg_debug_session(sess, GG_DEBUG_MISC, "// WARNING! " + "unable to verify peer certificate! " if (sess->ssl_flag == GG_SSL_REQUIRED) {
e->event.failure = GG_FAILURE_TLS;
@@ -1366,6 +1438,7 @@
+#if defined(GG_CONFIG_HAVE_GNUTLS) || defined(GG_CONFIG_HAVE_OPENSSL) gg_debug_session(sess, GG_DEBUG_MISC, "// WARNING! unable to verify hostname\n");
@@ -1380,9 +1453,12 @@
sess->timeout = GG_DEFAULT_TIMEOUT;
-static gg_action_t gg_handle_reading_proxy_gg(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_reading_proxy_gg(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -1394,12 +1470,15 @@
gg_debug_session(sess, GG_DEBUG_MISC, "recv() = %d\n", res);
if (res == -1 && (errno == EAGAIN || errno == EINTR)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() non-critical recv error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "non-critical recv error (errno=%d, %s)\n", + errno, strerror(errno)); - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() recv error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() recv " + "error (errno=%d, %s)\n", errno, strerror(errno)); e->event.failure = GG_FAILURE_CONNECTING;
@@ -1428,7 +1507,7 @@
/* szukamy początku treści */
body = strstr(sess->recv_buf, "\r\n\r\n");
body = strstr(sess->recv_buf, "\n\n");
@@ -1443,8 +1522,7 @@
- if (res != 0 && body == NULL)
+ gg_debug_session(sess, GG_DEBUG_MISC, "// found body!\n"); gg_debug_session(sess, GG_DEBUG_TRAFFIC, "// received proxy reply:\n%s\n", sess->recv_buf);
@@ -1459,14 +1537,6 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() can't find body\n");
- e->event.failure = GG_FAILURE_CONNECTING;
- gg_debug_session(sess, GG_DEBUG_MISC, "// found body!\n");
if (sess->ssl_flag != GG_SSL_DISABLED) {
if (gg_session_init_ssl(sess) == -1) {
e->event.failure = GG_FAILURE_TLS;
@@ -1496,7 +1566,7 @@
sess->check = GG_CHECK_READ;
sess->timeout = GG_DEFAULT_TIMEOUT; /* Pierwszy pakiet musi przyjść */
- // Jeśli zbuforowaliśmy za dużo, przeanalizuj
+ /* Jeśli zbuforowaliśmy za dużo, przeanalizuj */ if (sess->recv_buf + sess->recv_done > body) {
sess->recv_done = sess->recv_done - (body - sess->recv_buf);
@@ -1512,7 +1582,9 @@
-static gg_action_t gg_handle_connected(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_connected(struct gg_session *sess, + struct gg_event *e, enum gg_state_t next_state, + enum gg_state_t alt_state, enum gg_state_t alt2_state) @@ -1524,15 +1596,21 @@
res = gg_read(sess, buf, sizeof(buf));
if (res == -1 && (errno == EAGAIN || errno == EINTR)) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() non-critical read error (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() " + "non-critical read error (errno=%d, %s)\n", + errno, strerror(errno));
if (res == -1 || res == 0) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() read error (errno=%d, %s)\n", errno, strerror(errno));
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() connection closed\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd()" + " read error (errno=%d, %s)\n", + errno, strerror(errno)); + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd()" + " connection closed\n"); if (sess->state == GG_STATE_DISCONNECTING && res == 0) {
e->type = GG_EVENT_DISCONNECT_ACK;
@@ -1569,11 +1647,16 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() gg_recv_packet failed (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd()" + " gg_recv_packet failed (errno=%d, %s)\n", + errno, strerror(errno)); - if (gg_session_handle_packet(sess, gh->type, (const char *) gh + sizeof(struct gg_header), gh->length, e) == -1) {
+ if (gg_session_handle_packet(sess, gh->type, + (const char *) gh + sizeof(struct gg_header), @@ -1590,7 +1673,9 @@
-static gg_action_t gg_handle_error(struct gg_session *sess, struct gg_event *e, enum gg_state_t next_state, enum gg_state_t alt_state, enum gg_state_t alt2_state)
+static gg_action_t gg_handle_error(struct gg_session *sess, struct gg_event *e, + enum gg_state_t next_state, enum gg_state_t alt_state, + enum gg_state_t alt2_state) struct gg_session_private *p = sess->private_data;
@@ -1603,6 +1688,7 @@
static const gg_state_transition_t handlers[] =
+ /* style:maxlinelength:start-ignore */ { GG_STATE_RESOLVE_HUB_SYNC, gg_handle_resolve_sync, GG_STATE_CONNECT_HUB, GG_STATE_SEND_HUB, 0 },
{ GG_STATE_RESOLVE_GG_SYNC, gg_handle_resolve_sync, GG_STATE_CONNECT_GG, GG_STATE_READING_KEY, 0 },
{ GG_STATE_RESOLVE_PROXY_HUB_SYNC, gg_handle_resolve_sync, GG_STATE_CONNECT_PROXY_HUB, GG_STATE_SEND_PROXY_HUB, 0 },
@@ -1651,6 +1737,7 @@
{ GG_STATE_CONNECTED, gg_handle_connected, 0, 0, 0 },
{ GG_STATE_DISCONNECTING, gg_handle_connected, 0, 0, 0 },
{ GG_STATE_ERROR, gg_handle_error, 0, 0, 0 },
+ /* style:maxlinelength:end-ignore */ struct gg_event *gg_eventqueue_add(struct gg_session *sess)
@@ -1743,15 +1830,22 @@
for (i = 0; i < sizeof(handlers) / sizeof(handlers[0]); i++) {
if (handlers[i].state == (enum gg_state_t) sess->state) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_watch_fd() %s\n", gg_debug_state(sess->state));
- res = (*handlers[i].handler)(sess, ge, handlers[i].next_state, handlers[i].alt_state, handlers[i].alt2_state);
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_watch_fd() %s\n", + gg_debug_state(sess->state)); + res = (*handlers[i].handler)(sess, ge, + handlers[i].next_state, + handlers[i].alt2_state); - gg_debug_session(sess, GG_DEBUG_MISC | GG_DEBUG_ERROR, "// gg_watch_fd() invalid state %s\n", gg_debug_state(sess->state));
+ gg_debug_session(sess, GG_DEBUG_MISC | GG_DEBUG_ERROR, + "// gg_watch_fd() invalid state %s\n", + gg_debug_state(sess->state)); ge->event.failure = GG_FAILURE_INTERNAL;
--- a/libpurple/protocols/gg/lib/handlers.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/handlers.c Mon Mar 24 20:01:11 2014 -0400
@@ -1,9 +1,9 @@
* (C) Copyright 2001-2011 Wojtek Kaniewski <wojtekka@irc.pl>
- * Robert J. Woźny <speedy@ziew.org>
- * Arkadiusz Miśkiewicz <arekm@pld-linux.org>
- * Tomasz Chiliński <chilek@chilan.com>
- * Adam Wysocki <gophi@ekg.chmurka.net>
+ * Robert J. Woźny <speedy@ziew.org> + * Arkadiusz Miśkiewicz <arekm@pld-linux.org> + * Tomasz Chiliński <chilek@chilan.com> + * Adam Wysocki <gophi@ekg.chmurka.net> * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License Version
@@ -27,10 +27,8 @@
@@ -164,7 +162,8 @@
-static int gg_session_handle_login110_ok(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_login110_ok(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG110LoginOK *msg = gg110_login_ok__unpack(NULL, len, (uint8_t*)ptr);
@@ -200,7 +199,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_welcome(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_welcome(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_welcome *w;
@@ -236,7 +236,9 @@
hash = gg_fix32(gg_login_hash((unsigned char*) gs->password, seed));
- gg_debug_session(gs, GG_DEBUG_DUMP, "// gg_watch_fd() challenge %.4x --> GG32 hash %.8x\n", seed, hash);
+ gg_debug_session(gs, GG_DEBUG_DUMP, "// gg_watch_fd() " + "challenge %.4x --> GG32 hash %.8x\n", memcpy(hash_buf, &hash, sizeof(hash));
@@ -250,7 +252,9 @@
if (gg_login_hash_sha1_2(gs->password, seed, hash_buf) == -1) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() gg_login_hash_sha1_2() failed, probably out of memory\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_watch_fd() gg_login_hash_sha1_2()" + " failed, probably out of memory\n"); ge->type = GG_EVENT_CONN_FAILED;
ge->event.failure = GG_FAILURE_INTERNAL;
@@ -262,7 +266,9 @@
for (i = 0; i < 40; i += 2)
snprintf(tmp + i, sizeof(tmp) - i, "%02x", hash_buf[i / 2]);
- gg_debug_session(gs, GG_DEBUG_DUMP, "// gg_watch_fd() challenge %.4x --> SHA1 hash: %s\n", seed, tmp);
+ gg_debug_session(gs, GG_DEBUG_DUMP, "// gg_watch_fd() " + "challenge %.4x --> SHA1 hash: %s\n", @@ -281,7 +287,8 @@
if (!getsockname(gs->fd, (struct sockaddr*) &sin, &sin_len)) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() detected address to %s\n", inet_ntoa(sin.sin_addr));
+ gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() " + "detected address to %s\n", inet_ntoa(sin.sin_addr)); local_ip = sin.sin_addr.s_addr;
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() unable to detect address\n");
@@ -328,7 +335,9 @@
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() sending packet failed. (errno=%d, %s)\n", errno, strerror(errno));
+ gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() " + "sending packet failed. (errno=%d, %s)\n", + errno, strerror(errno)); ge->type = GG_EVENT_CONN_FAILED;
ge->event.failure = GG_FAILURE_WRITING;
@@ -347,7 +356,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_login_ok(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_login_ok(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() login succeded\n");
ge->type = GG_EVENT_CONN_SUCCESS;
@@ -371,7 +381,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_login_failed(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_login_failed(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) if (type != GG_DISCONNECTING)
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd() login failed\n");
@@ -391,7 +402,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_send_msg_ack(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_send_msg_ack(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_send_msg_ack *s = (const struct gg_send_msg_ack*) ptr;
@@ -432,7 +444,7 @@
gg_debug_session(gs, GG_DEBUG_VERBOSE,
"// gg_session_handle_send_msg_ack_110() "
- "%s=%016llx %s=%016llx\n",
+ "%s=%016" PRIx64 " %s=%016" PRIx64 "\n", msg->has_msg_id ? "msg_id" : "0", msg->msg_id,
msg->has_conv_id ? "conv_id" : "0", msg->conv_id);
@@ -442,7 +454,7 @@
gg_debug_session(gs, GG_DEBUG_MISC,
"// gg_session_handle_send_msg_ack_110() "
- "got link (id=%llu) \"%s\"\n", link->id, link->url);
+ "got link (id=%" PRIx64 ") \"%s\"\n", link->id, link->url); ge->type = GG_EVENT_ACK110;
@@ -462,7 +474,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_pong(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_pong(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received a pong\n");
@@ -478,7 +491,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_disconnecting(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_disconnecting(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received disconnection warning\n");
@@ -492,7 +506,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_disconnect_ack(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_disconnect_ack(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received logoff acknowledge\n");
@@ -506,7 +521,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_xml_event(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_xml_event(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received XML event\n");
@@ -524,7 +540,8 @@
-static int gg_session_handle_event_110(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_event_110(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG110Event *msg = gg110_event__unpack(NULL, len, (uint8_t*)ptr);
@@ -533,7 +550,7 @@
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_event_110: "
- "received GG11 event (type=%d, id=%llx)\n", msg->type, msg->id);
+ "received GG11 event (type=%d, id=%" PRIx64 ")\n", msg->type, msg->id); if (msg->type == GG110_EVENT__TYPE__XML) {
ge->type = GG_EVENT_XML_EVENT;
@@ -566,7 +583,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_pubdir50_reply(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_pubdir50_reply(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received pubdir/search reply\n");
@@ -578,7 +596,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_userlist_reply(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_userlist_reply(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) @@ -599,7 +618,8 @@
unsigned int reply_len = (gs->userlist_reply != NULL) ? strlen(gs->userlist_reply) : 0;
- gg_debug_session(gs, GG_DEBUG_MISC, "userlist_reply=%p, len=%d\n", gs->userlist_reply, len);
+ gg_debug_session(gs, GG_DEBUG_MISC, "userlist_reply=%p, len=%" + GG_SIZE_FMT "\n", gs->userlist_reply, len); tmp = realloc(gs->userlist_reply, reply_len + len);
@@ -630,7 +650,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_dcc7_id_reply(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_dcc7_id_reply(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received dcc7 id packet\n");
@@ -642,7 +663,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_dcc7_accept(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_dcc7_accept(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received dcc7 accept\n");
@@ -651,10 +673,11 @@
* \internal Obsługuje pakiet GG_DCC7_NEW.
* Patrz gg_packet_handler_t
-static int gg_session_handle_dcc7_new(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_dcc7_new(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received dcc7 request\n");
@@ -663,10 +686,11 @@
* \internal Obsługuje pakiet GG_DCC7_REJECT.
* Patrz gg_packet_handler_t
-static int gg_session_handle_dcc7_reject(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_dcc7_reject(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received dcc7 reject\n");
@@ -675,10 +699,11 @@
* \internal Obsługuje pakiet GG_DCC7_INFO.
* Patrz gg_packet_handler_t
-static int gg_session_handle_dcc7_info(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_dcc7_info(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received dcc7 info\n");
@@ -695,7 +720,9 @@
* \param sender Numer nadawcy
* \param type Typ pakietu (NIE typ GG_MSG_OPTION_IMAGE_*)
-static void gg_image_queue_parse(struct gg_event *e, const char *p, unsigned int len, struct gg_session *sess, uin_t sender, uint32_t type)
+static void gg_image_queue_parse(struct gg_event *e, const char *p, + unsigned int len, struct gg_session *sess, uin_t sender, const struct gg_msg_image_reply *i = (const void*) p;
struct gg_image_queue *q, *qq;
@@ -727,7 +754,9 @@
- gg_debug_session(sess, GG_DEBUG_WARNING, "// gg_image_queue_parse() unknown image from %d, size=%d, crc32=%.8x\n", sender, i->size, i->crc32);
+ gg_debug_session(sess, GG_DEBUG_WARNING, + "// gg_image_queue_parse() unknown image from %d, " + "size=%d, crc32=%.8x\n", sender, i->size, i->crc32); @@ -743,7 +772,9 @@
p += sizeof(struct gg_msg_image_reply);
if (memchr(p, 0, len) == NULL) {
- gg_debug_session(sess, GG_DEBUG_ERROR, "// gg_image_queue_parse() malformed packet from %d, unlimited filename\n", sender);
+ gg_debug_session(sess, GG_DEBUG_ERROR, + "// gg_image_queue_parse() malformed packet " + "from %d, unlimited filename\n", sender); @@ -795,7 +826,7 @@
* \internal Analizuje informacje rozszerzone wiadomości.
* \param sess Struktura sesji.
* \param e Struktura zdarzenia.
* \param sender Numer nadawcy.
@@ -807,7 +838,9 @@
* zostać przekazany aplikacji, -2 jeśli wystąpił błąd ogólny, -3 jeśli
* wiadomość jest niepoprawna.
-static int gg_handle_recv_msg_options(struct gg_session *sess, struct gg_event *e, uin_t sender, const char *p, const char *packet_end, uint32_t packet_type)
+static int gg_handle_recv_msg_options(struct gg_session *sess, + struct gg_event *e, uin_t sender, const char *p, const char *packet_end, @@ -819,26 +852,37 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() packet out of bounds (1)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " packet out of bounds (1)\n"); count = gg_fix32(m->count);
- if (p + count * sizeof(uin_t) > packet_end || p + count * sizeof(uin_t) < p || count > 0xffff) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() packet out of bounds (1.5)\n");
+ if (p + count * sizeof(uin_t) > packet_end || + p + count * sizeof(uin_t) < p || + gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " packet out of bounds (1.5)\n"); if (e->event.msg.recipients != NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() e->event.msg.recipients already exist\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " e->event.msg.recipients already exist\n"); e->event.msg.recipients = malloc(count * sizeof(uin_t));
if (e->event.msg.recipients == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() not enough memory for recipients data\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " not enough memory for recipients data\n"); @@ -859,7 +903,9 @@
if (p + 3 > packet_end) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() packet out of bounds (2)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " packet out of bounds (2)\n"); @@ -867,21 +913,27 @@
if (e->event.msg.formats != NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() e->event.msg.formats already exist\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " e->event.msg.formats already exist\n"); - gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() not enough memory for richtext data\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " not enough memory for richtext data\n"); if (p + len > packet_end) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() packet out of bounds (3)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " packet out of bounds (3)\n"); @@ -901,12 +953,16 @@
const struct gg_msg_image_request *i = (const void*) p;
if (p + sizeof(*i) > packet_end) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg() packet out of bounds (3)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg() " + "packet out of bounds (3)\n"); if (e->event.msg.formats != NULL || e->event.msg.recipients != NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() mixed options (1)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options()" + " mixed options (1)\n"); @@ -925,7 +981,9 @@
struct gg_msg_image_reply *rep = (void*) p;
if (e->event.msg.formats != NULL || e->event.msg.recipients != NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg_options() mixed options (2)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg_options() " + "mixed options (2)\n"); @@ -943,7 +1001,9 @@
} else if (p + sizeof(struct gg_msg_image_reply) + 1 > packet_end) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg() packet out of bounds (4)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg() " + "packet out of bounds (4)\n"); @@ -956,7 +1016,9 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg() unknown payload 0x%.2x\n", *p);
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg() " + "unknown payload 0x%.2x\n", *p); @@ -1002,17 +1064,19 @@
* \internal Obsługuje pakiet GG_RECV_MSG.
* Patrz gg_packet_handler_t
-static int gg_session_handle_recv_msg(struct gg_session *sess, uint32_t type, const char *packet, size_t length, struct gg_event *e)
+static int gg_session_handle_recv_msg(struct gg_session *sess, uint32_t type, + const char *packet, size_t length, struct gg_event *e) const struct gg_recv_msg *r = (const struct gg_recv_msg*) packet;
const char *payload = packet + sizeof(struct gg_recv_msg);
const char *payload_end = packet + length;
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_handle_recv_msg(%p, %d, %p);\n", packet, length, e);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_handle_recv_msg(%p, %" + GG_SIZE_FMT ", %p);\n", packet, length, e); @@ -1028,14 +1092,16 @@
options = memchr(payload, 0, (size_t) (payload_end - payload));
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg() malformed packet, message out of bounds (0)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg() malformed packet, " + "message out of bounds (0)\n");
length = (size_t) (options - payload);
switch (gg_handle_recv_msg_options(sess, e, gg_fix32(r->sender), options + 1, payload_end, type)) {
@@ -1057,13 +1123,16 @@
e->event.msg.time = gg_fix32(r->time);
e->event.msg.seq = gg_fix32(r->seq);
- e->event.msg.message = (unsigned char*) gg_encoding_convert(payload, GG_ENCODING_CP1250, sess->encoding, length, -1);
+ e->event.msg.message = (unsigned char*)gg_encoding_convert(payload, + GG_ENCODING_CP1250, sess->encoding, length, -1); if (e->event.msg.message == NULL) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_session_handle_recv_msg() out of memory\n");
- len = gg_message_text_to_html(NULL, (char*) e->event.msg.message, sess->encoding, e->event.msg.formats, e->event.msg.formats_length);
+ len = gg_message_text_to_html(NULL, (char*)e->event.msg.message, + sess->encoding, e->event.msg.formats, + e->event.msg.formats_length); e->event.msg.xhtml_message = malloc(len + 1);
if (e->event.msg.xhtml_message == NULL) {
@@ -1071,7 +1140,9 @@
- gg_message_text_to_html(e->event.msg.xhtml_message, (char*) e->event.msg.message, sess->encoding, e->event.msg.formats, e->event.msg.formats_length);
+ gg_message_text_to_html(e->event.msg.xhtml_message, + (char*)e->event.msg.message, sess->encoding, + e->event.msg.formats, e->event.msg.formats_length); gg_session_send_msg_ack(sess, gg_fix32(r->seq));
@@ -1095,16 +1166,19 @@
* \internal Obsługuje pakiet GG_RECV_MSG80.
* Patrz gg_packet_handler_t
-static int gg_session_handle_recv_msg_80(struct gg_session *sess, uint32_t type, const char *packet, size_t length, struct gg_event *e)
+static int gg_session_handle_recv_msg_80(struct gg_session *sess, uint32_t type, + const char *packet, size_t length, struct gg_event *e) const struct gg_recv_msg80 *r = (const struct gg_recv_msg80*) packet;
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_handle_recv_msg80(%p, %d, %p);\n", packet, length, e);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, + "** gg_handle_recv_msg80(%p, %" GG_SIZE_FMT ", %p);\n", @@ -1118,13 +1192,17 @@
offset_attr = gg_fix32(r->offset_attr);
if (offset_plain < sizeof(struct gg_recv_msg80) || offset_plain >= length) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg80() malformed packet, message out of bounds (0)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg80() malformed packet, " + "message out of bounds (0)\n"); if (offset_attr < sizeof(struct gg_recv_msg80) || offset_attr > length) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg80() malformed packet, attr out of bounds (1)\n");
- offset_attr = 0; /* nie parsuj attr. */
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg80() malformed packet, " + "attr out of bounds (1)\n"); + offset_attr = 0; /* nie parsuj attr. */ /* Normalna sytuacja, więc nie podpada pod powyższy warunek. */
@@ -1132,12 +1210,19 @@
if (memchr(packet + offset_plain, 0, length - offset_plain) == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg80() malformed packet, message out of bounds (2)\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg80() malformed packet, " + "message out of bounds (2)\n"); - if (offset_plain > sizeof(struct gg_recv_msg80) && memchr(packet + sizeof(struct gg_recv_msg80), 0, offset_plain - sizeof(struct gg_recv_msg80)) == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_handle_recv_msg80() malformed packet, message out of bounds (3)\n");
+ if (offset_plain > sizeof(struct gg_recv_msg80) && memchr(packet + + sizeof(struct gg_recv_msg80), 0, offset_plain - + sizeof(struct gg_recv_msg80)) == NULL) + gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_handle_recv_msg80() malformed packet, " + "message out of bounds (3)\n"); @@ -1148,7 +1233,9 @@
e->event.msg.seq = gg_fix32(r->seq);
- switch (gg_handle_recv_msg_options(sess, e, gg_fix32(r->sender), packet + offset_attr, packet + length, type)) {
+ switch (gg_handle_recv_msg_options(sess, e, gg_fix32(r->sender), + packet + offset_attr, packet + length, type)) gg_session_send_msg_ack(sess, gg_fix32(r->seq));
@@ -1172,11 +1259,15 @@
if (offset_plain > sizeof(struct gg_recv_msg80)) {
- len = gg_message_html_to_text(NULL, NULL, &fmt_len, packet + sizeof(struct gg_recv_msg80), GG_ENCODING_UTF8);
+ len = gg_message_html_to_text(NULL, NULL, &fmt_len, + packet + sizeof(struct gg_recv_msg80), e->event.msg.message = malloc(len + 1);
if (e->event.msg.message == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_session_handle_recv_msg_80() out of memory\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_session_handle_recv_msg_80() " @@ -1185,23 +1276,34 @@
e->event.msg.formats = malloc(fmt_len);
if (e->event.msg.formats == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_session_handle_recv_msg_80() out of memory\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_session_handle_recv_msg_80() " - gg_message_html_to_text((char*) e->event.msg.message, e->event.msg.formats, NULL, packet + sizeof(struct gg_recv_msg80), GG_ENCODING_UTF8);
+ gg_message_html_to_text((char*)e->event.msg.message, + e->event.msg.formats, NULL, + packet + sizeof(struct gg_recv_msg80), - e->event.msg.message = (unsigned char*) gg_encoding_convert(packet + offset_plain, GG_ENCODING_CP1250, sess->encoding, -1, -1);
+ e->event.msg.message = (unsigned char*)gg_encoding_convert( + packet + offset_plain, GG_ENCODING_CP1250, + sess->encoding, -1, -1); if (e->event.msg.message == NULL) {
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_session_handle_recv_msg_80() out of memory\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_session_handle_recv_msg_80() " if (offset_plain > sizeof(struct gg_recv_msg80)) {
- e->event.msg.xhtml_message = gg_encoding_convert(packet + sizeof(struct gg_recv_msg80), GG_ENCODING_UTF8, sess->encoding, -1, -1);
+ e->event.msg.xhtml_message = gg_encoding_convert( + packet + sizeof(struct gg_recv_msg80), GG_ENCODING_UTF8, + sess->encoding, -1, -1); if (e->event.msg.xhtml_message == NULL) {
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_session_handle_recv_msg_80() out of memory\n");
@@ -1210,7 +1312,9 @@
- len = gg_message_text_to_html(NULL, (char*) e->event.msg.message, sess->encoding, e->event.msg.formats, e->event.msg.formats_length);
+ len = gg_message_text_to_html(NULL, + (char*)e->event.msg.message, sess->encoding, + e->event.msg.formats, e->event.msg.formats_length); e->event.msg.xhtml_message = malloc(len + 1);
if (e->event.msg.xhtml_message == NULL) {
@@ -1218,7 +1322,9 @@
- gg_message_text_to_html(e->event.msg.xhtml_message, (char*) e->event.msg.message, sess->encoding, e->event.msg.formats, e->event.msg.formats_length);
+ gg_message_text_to_html(e->event.msg.xhtml_message, + (char*)e->event.msg.message, sess->encoding, + e->event.msg.formats, e->event.msg.formats_length); gg_session_send_msg_ack(sess, gg_fix32(r->seq));
@@ -1241,7 +1347,8 @@
-static int gg_session_handle_recv_msg_110(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_recv_msg_110(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG110RecvMessage *msg = gg110_recv_message__unpack(NULL, len, (uint8_t*)ptr);
@@ -1251,8 +1358,8 @@
struct gg_event_msg *ev = &ge->event.msg;
gg_debug_session(gs, GG_DEBUG_FUNCTION,
- "** gg_session_handle_recv_msg_110(%p, %d, %p);\n",
+ "** gg_session_handle_recv_msg_110(%p, %" GG_SIZE_FMT + ", %p);\n", ptr, len, ge); if (!GG_PROTOBUF_VALID(gs, "GG110RecvMessage", msg))
@@ -1268,7 +1375,7 @@
msg->conv_id = msg->has_conv_id ? msg->conv_id : 0;
gg_debug_session(gs, GG_DEBUG_VERBOSE,
"// gg_session_handle_recv_msg_110() "
- "msg_id=%016llx conv_id=%016llx\n",
+ "msg_id=%016" PRIx64 " conv_id=%016" PRIx64 "\n", msg->msg_id, msg->conv_id);
@@ -1383,10 +1490,11 @@
* \internal Obsługuje pakiet GG_STATUS.
* Patrz gg_packet_handler_t
-static int gg_session_handle_status(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_status(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_status *s = (const void*) ptr;
@@ -1398,7 +1506,8 @@
ge->event.status.descr = NULL;
- ge->event.status.descr = gg_encoding_convert(ptr + sizeof(*s), GG_ENCODING_CP1250, gs->encoding, len - sizeof(*s), -1);
+ ge->event.status.descr = gg_encoding_convert(ptr + sizeof(*s), + GG_ENCODING_CP1250, gs->encoding, len - sizeof(*s), -1); if (ge->event.status.descr == NULL) {
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() out of memory\n");
@@ -1411,10 +1520,11 @@
* \internal Obsługuje pakiety GG_STATUS60, GG_STATUS77 i GG_STATUS80BETA.
* Patrz gg_packet_handler_t
-static int gg_session_handle_status_60_77_80beta(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_status_60_77_80beta(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_status60 *s60 = (const void*) ptr;
const struct gg_status77 *s77 = (const void*) ptr;
@@ -1459,7 +1569,9 @@
descr_len = len - struct_len;
- ge->event.status60.descr = gg_encoding_convert(ptr + struct_len, (type == GG_STATUS80BETA) ? GG_ENCODING_UTF8 : GG_ENCODING_CP1250, gs->encoding, descr_len, -1);
+ ge->event.status60.descr = gg_encoding_convert(ptr + struct_len, + (type == GG_STATUS80BETA) ? GG_ENCODING_UTF8 : GG_ENCODING_CP1250, + gs->encoding, descr_len, -1); if (ge->event.status60.descr == NULL) {
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() out of memory\n");
@@ -1478,17 +1590,21 @@
* \internal Obsługuje pakiet GG_NOTIFY_REPLY.
* Patrz gg_packet_handler_t
-static int gg_session_handle_notify_reply(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_notify_reply(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_notify_reply *n = (const void*) ptr;
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() received a notify reply\n");
- if (gg_fix32(n->status) == GG_STATUS_BUSY_DESCR || gg_fix32(n->status) == GG_STATUS_NOT_AVAIL_DESCR || gg_fix32(n->status) == GG_STATUS_AVAIL_DESCR) {
+ if (gg_fix32(n->status) == GG_STATUS_BUSY_DESCR || + gg_fix32(n->status) == GG_STATUS_NOT_AVAIL_DESCR || + gg_fix32(n->status) == GG_STATUS_AVAIL_DESCR) ge->type = GG_EVENT_NOTIFY_DESCR;
@@ -1542,10 +1658,11 @@
* \internal Obsługuje pakiet GG_STATUS80.
* Patrz gg_packet_handler_t
-static int gg_session_handle_status_80(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_status_80(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_notify_reply80 *n = (const void*) ptr;
@@ -1565,7 +1682,9 @@
descr_len = gg_fix32(n->descr_len);
if (descr_len != 0 && sizeof(struct gg_notify_reply80) + descr_len <= len) {
- ge->event.status60.descr = gg_encoding_convert((const char*) n + sizeof(struct gg_notify_reply80), GG_ENCODING_UTF8, gs->encoding, descr_len, -1);
+ ge->event.status60.descr = gg_encoding_convert( + (const char*) n + sizeof(struct gg_notify_reply80), + GG_ENCODING_UTF8, gs->encoding, descr_len, -1); if (ge->event.status60.descr == NULL) {
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() out of memory\n");
@@ -1580,10 +1699,11 @@
* \internal Obsługuje pakiet GG_NOTIFY_REPLY80.
* Patrz gg_packet_handler_t
-static int gg_session_handle_notify_reply_80(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_notify_reply_80(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_notify_reply80 *n = (const void*) ptr;
unsigned int length = len, i = 0;
@@ -1622,10 +1742,14 @@
if (sizeof(struct gg_notify_reply80) + descr_len <= length) {
- ge->event.notify60[i].descr = gg_encoding_convert((const char*) n + sizeof(struct gg_notify_reply80), GG_ENCODING_UTF8, gs->encoding, descr_len, -1);
+ ge->event.notify60[i].descr = gg_encoding_convert( + (const char*) n + sizeof(struct gg_notify_reply80), + GG_ENCODING_UTF8, gs->encoding, descr_len, -1); if (ge->event.notify60[i].descr == NULL) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() out of memory\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_watch_fd_connected() " @@ -1657,10 +1781,11 @@
* \internal Obsługuje pakiety GG_NOTIFY_REPLY77 i GG_NOTIFY_REPLY80BETA.
* Patrz gg_packet_handler_t
-static int gg_session_handle_notify_reply_77_80beta(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_notify_reply_77_80beta(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_notify_reply77 *n = (const void*) ptr;
unsigned int length = len, i = 0;
@@ -1701,15 +1826,20 @@
unsigned char descr_len = *((const char*) n + sizeof(struct gg_notify_reply77));
if (sizeof(struct gg_notify_reply77) + descr_len <= length) {
- ge->event.notify60[i].descr = gg_encoding_convert((const char*) n + sizeof(struct gg_notify_reply77) + 1, (type == GG_NOTIFY_REPLY80BETA) ? GG_ENCODING_UTF8 : GG_ENCODING_CP1250, gs->encoding, descr_len, -1);
+ ge->event.notify60[i].descr = gg_encoding_convert( + (const char*) n + sizeof(struct gg_notify_reply77) + 1, + (type == GG_NOTIFY_REPLY80BETA) ? GG_ENCODING_UTF8 : GG_ENCODING_CP1250, + gs->encoding, descr_len, -1); if (ge->event.notify60[i].descr == NULL) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() out of memory\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_watch_fd_connected() "
length -= sizeof(struct gg_notify_reply77) + descr_len + 1;
n = (const void*) ((const char*) n + sizeof(struct gg_notify_reply77) + descr_len + 1);
@@ -1736,10 +1866,11 @@
* \internal Obsługuje pakiet GG_NOTIFY_REPLY60.
* Patrz gg_packet_handler_t
-static int gg_session_handle_notify_reply_60(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_notify_reply_60(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_notify_reply60 *n = (const void*) ptr;
unsigned int length = len, i = 0;
@@ -1780,17 +1911,22 @@
if (sizeof(struct gg_notify_reply60) + descr_len <= length) {
- descr = gg_encoding_convert((const char*) n + sizeof(struct gg_notify_reply60) + 1, GG_ENCODING_CP1250, gs->encoding, descr_len, -1);
+ descr = gg_encoding_convert((const char*) n + + sizeof(struct gg_notify_reply60) + 1, + GG_ENCODING_CP1250, gs->encoding, - gg_debug_session(gs, GG_DEBUG_MISC, "// gg_watch_fd_connected() out of memory\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_watch_fd_connected() " ge->event.notify60[i].descr = descr;
length -= sizeof(struct gg_notify_reply60) + descr_len + 1;
n = (const void*) ((const char*) n + sizeof(struct gg_notify_reply60) + descr_len + 1);
@@ -1817,10 +1953,11 @@
* \internal Obsługuje pakiet GG_USER_DATA.
* Patrz gg_packet_handler_t
-static int gg_session_handle_user_data(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_user_data(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const char *p = (const char*) ptr;
@@ -1852,7 +1989,10 @@
users = calloc(d.user_count, sizeof(struct gg_event_user_data_user));
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() out of memory (%d*%d)\n", d.user_count, sizeof(struct gg_event_user_data_user));
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() out of memory" + " (%d*%" GG_SIZE_FMT ")\n", d.user_count, + sizeof(struct gg_event_user_data_user)); @@ -1863,7 +2003,7 @@
ge->event.user_data.type = d.type;
ge->event.user_data.user_count = d.user_count;
ge->event.user_data.users = users;
gg_debug_session(gs, GG_DEBUG_DUMP, "type=%d, count=%d\n", d.type, d.user_count);
for (i = 0; i < d.user_count; i++) {
@@ -1890,7 +2030,11 @@
attrs = calloc(u.attr_count, sizeof(struct gg_event_user_data_attr));
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() out of memory (%d*%d)\n", u.attr_count, sizeof(struct gg_event_user_data_attr));
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() " + "out of memory (%d*%" GG_SIZE_FMT + sizeof(struct gg_event_user_data_attr)); @@ -1911,7 +2055,9 @@
if (p + sizeof(key_size) > packet_end) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() malformed packet (3)\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data()" + "malformed packet (3)\n"); @@ -1921,14 +2067,18 @@
key_size = gg_fix32(key_size);
if (key_size > 0xffff || p + key_size > packet_end) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() malformed packet (3)\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() " + "malformed packet (3)\n"); key = malloc(key_size + 1);
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() out of memory (%d)\n", key_size + 1);
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() " + "out of memory (%d)\n", key_size + 1); @@ -1940,7 +2090,9 @@
if (p + sizeof(attr_type) + sizeof(value_size) > packet_end) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() malformed packet (4)\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() " + "malformed packet (4)\n"); @@ -1953,14 +2105,18 @@
value_size = gg_fix32(value_size);
if (value_size > 0xffff || p + value_size > packet_end) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() malformed packet (5)\n");
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() " + "malformed packet (5)\n"); value = malloc(value_size + 1);
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_session_handle_user_data() out of memory (%d)\n", value_size + 1);
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_session_handle_user_data() " + "out of memory (%d)\n", value_size + 1); @@ -1971,7 +2127,8 @@
- gg_debug_session(gs, GG_DEBUG_DUMP, " key=\"%s\", type=%d, value=\"%s\"\n", key, attr_type, value);
+ gg_debug_session(gs, GG_DEBUG_DUMP, " key=\"%s\", " + "type=%d, value=\"%s\"\n", key, attr_type, value); @@ -1999,10 +2156,11 @@
* \internal Obsługuje pakiet GG_TYPING_NOTIFICATION.
* Patrz gg_packet_handler_t
-static int gg_session_handle_typing_notification(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_typing_notification(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_typing_notification *n = (const void*) ptr;
@@ -2020,10 +2178,11 @@
* \internal Obsługuje pakiet GG_MULTILOGON_INFO.
* Patrz gg_packet_handler_t
-static int gg_session_handle_multilogon_info(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_multilogon_info(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const char *packet_end = (const char*) ptr + len;
const struct gg_multilogon_info *info = (const struct gg_multilogon_info*) ptr;
@@ -2045,10 +2204,13 @@
sessions = calloc(count, sizeof(struct gg_multilogon_session));
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_handle_multilogon_info() out of memory (%d*%d)\n", count, sizeof(struct gg_multilogon_session));
+ gg_debug_session(gs, GG_DEBUG_MISC, "// " + "gg_handle_multilogon_info() out of memory (%" + GG_SIZE_FMT "*%" GG_SIZE_FMT ")\n", + count, sizeof(struct gg_multilogon_session));
ge->type = GG_EVENT_MULTILOGON_INFO;
ge->event.multilogon_info.count = count;
ge->event.multilogon_info.sessions = sessions;
@@ -2082,7 +2244,9 @@
sessions[i].name = malloc(name_size + 1);
if (sessions[i].name == NULL) {
- gg_debug_session(gs, GG_DEBUG_MISC, "// gg_handle_multilogon_info() out of memory (%d)\n", name_size);
+ gg_debug_session(gs, GG_DEBUG_MISC, + "// gg_handle_multilogon_info() out of " + "memory (%" GG_SIZE_FMT ")\n", name_size); @@ -2113,7 +2277,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_userlist_100_version(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_userlist_100_version(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_userlist100_version *version = (const struct gg_userlist100_version*) ptr;
@@ -2130,7 +2295,8 @@
* Patrz gg_packet_handler_t
-static int gg_session_handle_userlist_100_reply(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_userlist_100_reply(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_userlist100_reply *reply = (const struct gg_userlist100_reply*) ptr;
@@ -2139,7 +2305,7 @@
if (len > sizeof(*reply)) {
data = gg_inflate((const unsigned char*) ptr + sizeof(*reply), len - sizeof(*reply));
gg_debug_session(gs, GG_DEBUG_MISC, "// gg_handle_userlist_100_reply() gg_inflate() failed\n");
@@ -2155,7 +2321,8 @@
-static int gg_session_handle_imtoken(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_imtoken(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG110Imtoken *msg = gg110_imtoken__unpack(NULL, len, (uint8_t*)ptr);
@@ -2199,7 +2366,8 @@
-static int gg_session_handle_chat_info(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_chat_info(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) @@ -2241,8 +2409,7 @@
- for (i = 0; i < participants_count && gg_tvbuff_is_valid(tvb); i++)
+ for (i = 0; i < participants_count && gg_tvbuff_is_valid(tvb); i++) { participants[i] = gg_tvbuff_read_uint32(tvb);
gg_tvbuff_read_uint32(tvb); /* 0x1e lub 0x18 */
@@ -2258,7 +2425,8 @@
if (0 != gg_chat_update(gs, id, version, participants,
@@ -2268,11 +2436,12 @@
ge->event.chat_info.version = version;
ge->event.chat_info.participants_count = participants_count;
ge->event.chat_info.participants = participants;
-static int gg_session_handle_chat_info_update(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_chat_info_update(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) GG110ChatInfoUpdate *msg = gg110_chat_info_update__unpack(NULL, len, (uint8_t*)ptr);
@@ -2283,7 +2452,8 @@
gg_debug_session(gs, GG_DEBUG_VERBOSE,
"// gg_session_handle_chat_info_update() "
- "msg_id=%016llx conv_id=%016llx\n", msg->msg_id, msg->conv_id);
+ "msg_id=%016" PRIx64 " conv_id=%016" PRIx64 "\n", + msg->msg_id, msg->conv_id); ge->type = GG_EVENT_CHAT_INFO_UPDATE;
ge->event.chat_info_update.id = msg->chat_id;
@@ -2301,8 +2471,18 @@
chat->version = msg->version;
if (msg->update_type == GG_CHAT_INFO_UPDATE_ENTERED) {
+ uin_t *old_part = chat->participants; + chat->participants = realloc(chat->participants, + sizeof(uin_t) * chat->participants_count); + if (chat->participants == NULL) { + chat->participants = old_part; + gg_debug_session(gs, GG_DEBUG_ERROR, + "// gg_session_handle_chat_info_update() " + "out of memory (count=%u)\n", + chat->participants_count); chat->participants_count++;
- chat->participants = realloc(chat->participants, sizeof(uin_t) * chat->participants_count);
chat->participants[chat->participants_count - 1] = participant;
} else if (msg->update_type == GG_CHAT_INFO_UPDATE_EXITED) {
@@ -2318,7 +2498,8 @@
free(chat->participants);
chat->participants = NULL;
- chat->participants = realloc(chat->participants, sizeof(uin_t) * chat->participants_count);
+ chat->participants = realloc(chat->participants, + sizeof(uin_t)*chat->participants_count); @@ -2327,7 +2508,8 @@
-static int gg_session_handle_chat_created(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_chat_created(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_chat_created *p = (const struct gg_chat_created *)ptr;
@@ -2340,7 +2522,8 @@
-static int gg_session_handle_chat_invite_ack(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_chat_invite_ack(struct gg_session *gs, + uint32_t type, const char *ptr, size_t len, struct gg_event *ge) const struct gg_chat_invite_ack *p =
(const struct gg_chat_invite_ack *)ptr;
@@ -2348,11 +2531,12 @@
ge->type = GG_EVENT_CHAT_INVITE_ACK;
ge->event.chat_invite_ack.id = gg_fix64(p->id);
ge->event.chat_invite_ack.seq = gg_fix32(p->seq);
-static int gg_session_handle_chat_left(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_chat_left(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) const struct gg_chat_left *p = (const struct gg_chat_left *)ptr;
@@ -2369,7 +2553,8 @@
-static int gg_session_handle_options(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_options(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG110Options *msg = gg110_options__unpack(NULL, len, (uint8_t*)ptr);
@@ -2393,7 +2578,8 @@
-static int gg_session_handle_access_info(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_access_info(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG110AccessInfo *msg = gg110_access_info__unpack(NULL, len, (uint8_t*)ptr);
@@ -2402,7 +2588,7 @@
gg_debug_session(gs, GG_DEBUG_MISC,
"// gg_session_handle_access_info: dummy[%02x, %02x], "
- "last[message=%lu, file_transfer=%lu, conference_ch=%lu]\n",
+ "last[message=%u, file_transfer=%u, conference_ch=%u]\n", msg->dummy1, msg->dummy2, msg->last_message,
msg->last_file_transfer, msg->last_conference_ch);
@@ -2412,7 +2598,8 @@
/* ten pakiet jest odbierany tylko, jeżeli przy logowaniu użyliśmy identyfikatora typu 0x01 */
-static int gg_session_handle_uin_info(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_uin_info(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) char *uin1 = NULL, *uin2 = NULL;
@@ -2445,7 +2632,8 @@
-static int gg_session_handle_transfer_info(struct gg_session *gs, uint32_t type, const char *ptr, size_t len, struct gg_event *ge)
+static int gg_session_handle_transfer_info(struct gg_session *gs, uint32_t type, + const char *ptr, size_t len, struct gg_event *ge) GG112TransferInfo *msg = gg112_transfer_info__unpack(NULL, len, (uint8_t*)ptr);
@@ -2470,8 +2658,8 @@
gg_debug_session(gs, GG_DEBUG_MISC,
"// gg_session_handle_transfer_info: dummy1=%#x, time=%u, "
- "sender=%u, peer=%u, msg_id=%#016llx, "
+ "sender=%u, peer=%u, msg_id=%#016" PRIx64 ", " + "conv_id=%#016" PRIx64 "\n", msg->dummy1, msg->time, sender, peer, msg->msg_id,
@@ -2489,7 +2677,7 @@
gg_debug_session(gs, GG_DEBUG_MISC,
"// gg_session_handle_transfer_info file: "
"type=\"%s\", content_type=\"%s\", filename=\"%s\", "
- "filesize=%u, msg_id=%#016llx url=\"%s\"\n",
+ "filesize=%u, msg_id=%#016" PRIx64 " url=\"%s\"\n", file->type, file->content_type, file->filename,
file->filesize, file->msg_id, file->url);
@@ -2507,6 +2695,7 @@
static const gg_packet_handler_t handlers[] =
+ /* style:maxlinelength:start-ignore */ { GG_WELCOME, GG_STATE_READING_KEY, 0, gg_session_handle_welcome },
{ GG_LOGIN_OK, GG_STATE_READING_REPLY, 0, gg_session_handle_login_ok },
{ GG_LOGIN80_OK, GG_STATE_READING_REPLY, 0, gg_session_handle_login_ok },
@@ -2562,6 +2751,7 @@
{ GG_ACCESS_INFO, GG_STATE_CONNECTED, 0, gg_session_handle_access_info },
{ GG_UIN_INFO, GG_STATE_CONNECTED, 0, gg_session_handle_uin_info },
{ GG_TRANSFER_INFO, GG_STATE_CONNECTED, 0, gg_session_handle_transfer_info }
+ /* style:maxlinelength:end-ignore */ @@ -2579,7 +2769,9 @@
- gg_debug_session(gs, GG_DEBUG_FUNCTION, "// gg_session_handle_packet(%d, %p, %d)\n", type, ptr, len);
+ gg_debug_session(gs, GG_DEBUG_FUNCTION, + "// gg_session_handle_packet(%d, %p, %" GG_SIZE_FMT ")\n", gs->last_event = time(NULL);
@@ -2590,7 +2782,9 @@
- gg_debug_session(gs, GG_DEBUG_ERROR, "// gg_session_handle_packet() out of memory (%d bytes)\n", len);
+ gg_debug_session(gs, GG_DEBUG_ERROR, + "// gg_session_handle_packet() out of memory " @@ -2610,20 +2804,26 @@
if (handlers[i].state != 0 && handlers[i].state != (enum gg_state_t) gs->state) {
- gg_debug_session(gs, GG_DEBUG_WARNING, "// gg_session_handle_packet() packet 0x%02x unexpected in state %d\n", type, gs->state);
+ gg_debug_session(gs, GG_DEBUG_WARNING, + "// gg_session_handle_packet() packet 0x%02x " + "unexpected in state %d\n", type, gs->state); if (len < handlers[i].min_length) {
- gg_debug_session(gs, GG_DEBUG_ERROR, "// gg_session_handle_packet() packet 0x%02x too short (%d bytes)\n", type, len);
+ gg_debug_session(gs, GG_DEBUG_ERROR, + "// gg_session_handle_packet() packet 0x%02x " + "too short (%" GG_SIZE_FMT " bytes)\n", return (*handlers[i].handler)(gs, type, ptr, len, ge);
- gg_debug_session(gs, GG_DEBUG_WARNING, "// gg_session_handle_packet() unhandled packet 0x%02x, len %d, state %d\n", type, len, gs->state);
+ gg_debug_session(gs, GG_DEBUG_WARNING, "// gg_session_handle_packet() " + "unhandled packet 0x%02x, len %" GG_SIZE_FMT ", state %d\n",
--- a/libpurple/protocols/gg/lib/libgadu.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/libgadu.c Mon Mar 24 20:01:11 2014 -0400
@@ -2,10 +2,10 @@
* (C) Copyright 2001-2010 Wojtek Kaniewski <wojtekka@irc.pl>
- * Robert J. Woźny <speedy@ziew.org>
- * Arkadiusz Miśkiewicz <arekm@pld-linux.org>
- * Tomasz Chiliński <chilek@chilan.com>
- * Adam Wysocki <gophi@ekg.chmurka.net>
+ * Robert J. Woźny <speedy@ziew.org> + * Arkadiusz Miśkiewicz <arekm@pld-linux.org> + * Tomasz Chiliński <chilek@chilan.com> + * Adam Wysocki <gophi@ekg.chmurka.net> * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License Version
@@ -30,9 +30,7 @@
@@ -62,7 +60,7 @@
* Port gniazda nasłuchującego dla połączeń bezpośrednich.
@@ -126,11 +124,7 @@
-__attribute__ ((unused))
+static char rcsid[] GG_UNUSED = "$Id$"; @@ -175,7 +169,8 @@
gg_debug(GG_DEBUG_MISC | GG_DEBUG_ERROR,
- "//gg_new0(%zd) not enough memory\n", size);
+ "//gg_new0(%" GG_SIZE_FMT + ") not enough memory\n", size); @@ -450,8 +445,6 @@
* \internal Wysyła do serwera dane binarne.
@@ -568,6 +561,7 @@
gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_recv_packet(%p);\n", sess);
@@ -590,9 +584,21 @@
if ((size_t) sess->recv_done < sizeof(struct gg_header)) {
len = sizeof(struct gg_header) - sess->recv_done;
- gg_debug_session(sess, GG_DEBUG_NET, "// gg_recv_packet() header: %d done, %d to go\n", sess->recv_done, len);
+ gg_debug_session(sess, GG_DEBUG_NET, + "// gg_recv_packet() header: %d done, " + "%" GG_SIZE_FMT " to go\n", - uint32_t ghlen = gh ? gg_fix32(gh->length) : 0;
+ ghlen = gh ? gg_fix32(gh->length) : 0; + gg_debug_session(sess, GG_DEBUG_ERROR, + "// gg_recv_packet() invalid packet " + "length (%d)\n", ghlen); if ((size_t) sess->recv_done >= sizeof(struct gg_header) + ghlen) {
gg_debug_session(sess, GG_DEBUG_NET, "// gg_recv_packet() and that's it\n");
@@ -600,7 +606,10 @@
len = sizeof(struct gg_header) + ghlen - sess->recv_done;
- gg_debug_session(sess, GG_DEBUG_NET, "// gg_recv_packet() payload: %d done, %d length, %d to go\n", sess->recv_done, ghlen, len);
+ gg_debug_session(sess, GG_DEBUG_NET, + "// gg_recv_packet() payload: %d done, " + "%u length, %" GG_SIZE_FMT " to go\n", + sess->recv_done, ghlen, len); res = gg_read(sess, sess->recv_buf + sess->recv_done, len);
@@ -617,7 +626,9 @@
- gg_debug_session(sess, GG_DEBUG_ERROR, "// gg_recv_packet() read failed: errno=%d, %s\n", errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_ERROR, + "// gg_recv_packet() read failed: errno=%d, " + "%s\n", errno, strerror(errno)); @@ -625,15 +636,19 @@
if (sess->recv_done + res == sizeof(struct gg_header)) {
- uint32_t ghlen = gh ? gg_fix32(gh->length) : 0;
- gg_debug_session(sess, GG_DEBUG_NET, "// gg_recv_packet() header complete, payload %d bytes\n", ghlen);
+ ghlen = gh ? gg_fix32(gh->length) : 0; + gg_debug_session(sess, GG_DEBUG_NET, + "// gg_recv_packet() header complete, " + "payload %d bytes\n", ghlen); - gg_debug_session(sess, GG_DEBUG_ERROR, "// gg_recv_packet() invalid packet length (%d)\n", ghlen);
+ gg_debug_session(sess, GG_DEBUG_ERROR, + "// gg_recv_packet() invalid packet " + "length (%d)\n", ghlen); @@ -659,13 +674,14 @@
/* Czasami zakładamy, że teksty w pakietach są zakończone zerem */
- packet[sizeof(struct gg_header) + gg_fix32(gh->length)] = 0;
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet(type=0x%.2x, length=%d)\n", gg_fix32(gh->type), gg_fix32(gh->length));
- gg_debug_dump(sess, GG_DEBUG_DUMP, packet, sizeof(struct gg_header) + gg_fix32(gh->length));
+ packet[sizeof(struct gg_header) + ghlen] = 0; + gg_debug_session(sess, GG_DEBUG_MISC, "// gg_recv_packet(type=0x%.2x, " + "length=%d)\n", gg_fix32(gh->type), ghlen); + gg_debug_dump(sess, GG_DEBUG_DUMP, packet, sizeof(struct gg_header) + ghlen); gh->type = gg_fix32(gh->type);
- gh->length = gg_fix32(gh->length);
@@ -688,7 +704,7 @@
* \param sess Struktura sesji
* \param type Rodzaj pakietu
* \param ... Lista kolejnych części pakietu (wskaźnik na bufor i długość
- * typu \c int) zakończona \c NULL
+ * typu \c int) zakończona \c NULL * \return 0 jeśli się powiodło, -1 w przypadku błędu
@@ -741,7 +757,8 @@
h->type = gg_fix32(type);
h->length = gg_fix32(tmp_length - sizeof(struct gg_header));
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_send_packet(type=0x%.2x, length=%d)\n", gg_fix32(h->type), gg_fix32(h->length));
+ gg_debug_session(sess, GG_DEBUG_MISC, "// gg_send_packet(type=0x%.2x, " + "length=%d)\n", gg_fix32(h->type), gg_fix32(h->length)); gg_debug_dump(sess, GG_DEBUG_DUMP, tmp, tmp_length);
res = gg_write(sess, tmp, tmp_length);
@@ -749,12 +766,17 @@
- gg_debug_session(sess, GG_DEBUG_ERROR, "// gg_send_packet() write() failed. res = %d, errno = %d (%s)\n", res, errno, strerror(errno));
+ gg_debug_session(sess, GG_DEBUG_ERROR, "// gg_send_packet() " + "write() failed. res = %d, errno = %d (%s)\n", + res, errno, strerror(errno));
- gg_debug_session(sess, GG_DEBUG_NET, "// gg_send_packet() partial write(), %d sent, %d left, %d total left\n", res, tmp_length - res, sess->send_left);
+ gg_debug_session(sess, GG_DEBUG_NET, "// gg_send_packet() " + "partial write(), %d sent, %d left, %d total left\n", + res, tmp_length - res, sess->send_left); sess->check |= GG_CHECK_WRITE;
@@ -810,10 +832,10 @@
* obsługa SSL nie jest wkompilowana.
* \param p Struktura opisująca parametry połączenia. Wymagane pola: uin,
* \return Wskaźnik do zaalokowanej struktury sesji \c gg_session lub NULL
@@ -928,7 +950,8 @@
if (GG_LOGIN_PARAMS_HAS_FIELD(p, host_white_list) &&
- p->host_white_list != NULL) {
+ p->host_white_list != NULL) sess_private->host_white_list =
gg_strarr_dup(p->host_white_list);
if (sess_private->host_white_list == NULL)
@@ -936,7 +959,11 @@
if (p->protocol_features == 0) {
- sess->protocol_features = GG_FEATURE_MSG80 | GG_FEATURE_STATUS80 | GG_FEATURE_DND_FFC | GG_FEATURE_IMAGE_DESCR | GG_FEATURE_UNKNOWN_100 | GG_FEATURE_USER_DATA | GG_FEATURE_MSG_ACK | GG_FEATURE_TYPING_NOTIFICATION;
+ sess->protocol_features = GG_FEATURE_MSG80 | + GG_FEATURE_STATUS80 | GG_FEATURE_DND_FFC | + GG_FEATURE_IMAGE_DESCR | GG_FEATURE_UNKNOWN_100 | + GG_FEATURE_USER_DATA | GG_FEATURE_MSG_ACK | + GG_FEATURE_TYPING_NOTIFICATION; sess->protocol_features = (p->protocol_features & ~(GG_FEATURE_STATUS77 | GG_FEATURE_MSG77));
@@ -965,7 +992,8 @@
sess->encoding = p->encoding;
if (gg_session_set_resolver(sess, p->resolver) == -1) {
- gg_debug(GG_DEBUG_MISC, "// gg_login() invalid arguments. unsupported resolver type (%d)\n", p->resolver);
+ gg_debug(GG_DEBUG_MISC, "// gg_login() invalid arguments. " + "unsupported resolver type (%d)\n", p->resolver); @@ -977,9 +1005,9 @@
gg_debug(GG_DEBUG_MISC, "// gg_login() not enough memory for status\n");
/* XXX pamiętać, żeby nie ciąć w środku znaku utf-8 */
if (strlen(sess->initial_descr) > GG_STATUS_DESCR_MAXSIZE)
sess->initial_descr[GG_STATUS_DESCR_MAXSIZE] = 0;
@@ -1006,7 +1034,9 @@
sess->resolver_host = gg_proxy_host;
sess->proxy_port = gg_proxy_port;
- sess->state = (sess->async) ? GG_STATE_RESOLVE_PROXY_HUB_ASYNC : GG_STATE_RESOLVE_PROXY_HUB_SYNC;
+ sess->state = (sess->async) ? + GG_STATE_RESOLVE_PROXY_HUB_ASYNC : + GG_STATE_RESOLVE_PROXY_HUB_SYNC; sess->resolver_host = GG_APPMSG_HOST;
@@ -1016,7 +1046,7 @@
if (sess->connect_host != NULL)
- // XXX inet_ntoa i wielowątkowość
+ /* XXX inet_ntoa i wielowątkowość */ sess->connect_host = strdup(inet_ntoa(*(struct in_addr*) &sess->server_addr));
if (sess->connect_host == NULL)
@@ -1050,7 +1080,7 @@
- // XXX inaczej gg_watch_fd() wyjdzie z timeoutem
+ /* XXX inaczej gg_watch_fd() wyjdzie z timeoutem */ sess->timeout = GG_DEFAULT_TIMEOUT;
@@ -1086,8 +1116,6 @@
@@ -1222,13 +1250,20 @@
SSL_CTX_free(sess->ssl_ctx);
- sess->resolver_cleanup(&sess->resolver, 1);
+ if (sess->resolver_cleanup != NULL) + sess->resolver_cleanup(&sess->resolver, 1);
+ struct gg_image_queue *next = sess->images->next; gg_image_queue_remove(sess, sess->images, 1);
+ /* a fix for false-positive NULL-dereference */ for (dcc = sess->dcc7_list; dcc; dcc = dcc->next)
@@ -1326,11 +1361,9 @@
- res = gg_send_packet(sess, GG_NEW_STATUS80,
- "\x00", descr_null_len,
+ res = gg_send_packet(sess, GG_NEW_STATUS80, + &p, sizeof(p), descr, descr_len, + "\x00", descr_null_len, NULL); @@ -1356,7 +1389,9 @@
int gg_change_status_descr_time(struct gg_session *sess, int status, const char *descr, int ts)
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_change_status_descr_time(%p, %d, \"%s\", %d);\n", sess, status, descr, ts);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, + "** gg_change_status_descr_time(%p, %d, \"%s\", %d);\n", + sess, status, descr, ts); return gg_change_status_descr(sess, status, descr);
@@ -1402,7 +1437,7 @@
gg_debug_session(sess, GG_DEBUG_FUNCTION,
- "** gg_send_message_110(%p, %u, %llu, %p, %d);\n",
+ "** gg_send_message_110(%p, %u, %" PRIu64 ", %p, %d);\n", sess, recipient, chat_id, message, is_html);
@@ -1438,7 +1473,7 @@
if (plain_message_gen == NULL)
html_message = html_message_gen =
gg_message_text_to_html_110(plain_message, -1);
if (html_message_gen == NULL) {
@@ -1494,7 +1529,10 @@
-static int gg_send_message_common(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message, const unsigned char *format, int formatlen, const unsigned char *html_message)
+static int gg_send_message_common(struct gg_session *sess, int msgclass, + int recipients_count, uin_t *recipients, const unsigned char *message, + const unsigned char *format, int formatlen, + const unsigned char *html_message) struct gg_send_msg80 s80;
const char *cp_msg = NULL, *utf_html_msg = NULL;
@@ -1502,7 +1540,10 @@
unsigned char *generated_format = NULL;
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_common(%p, %d, %d, %p, %p, %p, %d, %p);\n", sess, msgclass, recipients_count, recipients, message, format, formatlen, html_message);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_common(" + "%p, %d, %d, %p, %p, %p, %d, %p);\n", sess, msgclass, + recipients_count, recipients, message, format, + formatlen, html_message); @@ -1514,12 +1555,16 @@
- if ((message == NULL && html_message == NULL) || recipients_count <= 0 || recipients_count > 0xffff || recipients == NULL || (format == NULL && formatlen != 0)) {
+ if ((message == NULL && html_message == NULL) || + recipients_count <= 0 || recipients_count > 0xffff || + recipients == NULL || (format == NULL && formatlen != 0)) - if (sess->protocol_version >= GG_PROTOCOL_VERSION_110 && recipients_count == 1)
+ if (sess->protocol_version >= GG_PROTOCOL_VERSION_110 && int is_html = (html_message != NULL);
seq_no = gg_send_message_110(sess, recipients[0], 0,
@@ -1528,8 +1573,11 @@
- if (sess->protocol_version >= GG_PROTOCOL_VERSION_110 && !gg_compat_feature_is_enabled(sess, GG_COMPAT_FEATURE_LEGACY_CONFER)) {
- gg_debug_session(sess, GG_DEBUG_MISC | GG_DEBUG_ERROR, "// gg_send_message_common() legacy conferences disabled\n");
+ if (sess->protocol_version >= GG_PROTOCOL_VERSION_110 && + !gg_compat_feature_is_enabled(sess, GG_COMPAT_FEATURE_LEGACY_CONFER)) + gg_debug_session(sess, GG_DEBUG_MISC | GG_DEBUG_ERROR, + "// gg_send_message_common() legacy conferences disabled\n"); @@ -1557,7 +1605,8 @@
generated_format[0] = '\x02';
fixed_fmt_len = gg_fix16(fmt_len);
memcpy(generated_format + 1, &fixed_fmt_len, sizeof(fixed_fmt_len));
- gg_message_html_to_text(tmp_msg, generated_format + 3, NULL, (const char*) html_message, sess->encoding);
+ gg_message_html_to_text(tmp_msg, generated_format + 3, + NULL, (const char*)html_message, sess->encoding); format = generated_format;
@@ -1579,7 +1628,9 @@
if (sess->encoding == GG_ENCODING_UTF8) {
- cp_msg = recoded_msg = gg_encoding_convert((const char*) message, sess->encoding, GG_ENCODING_CP1250, -1, -1);
+ cp_msg = recoded_msg = gg_encoding_convert( + (const char*)message, sess->encoding, + GG_ENCODING_CP1250, -1, -1); @@ -1598,7 +1649,9 @@
if (sess->encoding == GG_ENCODING_UTF8) {
utf_msg = (const char*) message;
- utf_msg = recoded_msg = gg_encoding_convert((const char*) message, sess->encoding, GG_ENCODING_UTF8, -1, -1);
+ utf_msg = recoded_msg = gg_encoding_convert( + (const char*)message, sess->encoding, + GG_ENCODING_UTF8, -1, -1); @@ -1623,7 +1676,9 @@
if (sess->encoding == GG_ENCODING_UTF8) {
utf_html_msg = (const char*) html_message;
- utf_html_msg = recoded_html_msg = gg_encoding_convert((const char*) html_message, sess->encoding, GG_ENCODING_UTF8, -1, -1);
+ utf_html_msg = recoded_html_msg = gg_encoding_convert( + (const char*)html_message, sess->encoding, + GG_ENCODING_UTF8, -1, -1); if (utf_html_msg == NULL)
@@ -1672,16 +1727,27 @@
s80.recipient = gg_fix32(recipients[i]);
- if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), utf_html_msg, strlen(utf_html_msg) + 1, cp_msg, strlen(cp_msg) + 1, &r, sizeof(r), recps, (recipients_count - 1) * sizeof(uin_t), format, formatlen, NULL) == -1)
+ if (gg_send_packet(sess, GG_SEND_MSG80, &s80, + sizeof(s80), utf_html_msg, + strlen(utf_html_msg) + 1, cp_msg, + strlen(cp_msg) + 1, &r, sizeof(r), recps, + (recipients_count - 1) * sizeof(uin_t), format, + formatlen, NULL) == -1) s80.recipient = gg_fix32(recipients[0]);
- if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), utf_html_msg, strlen(utf_html_msg) + 1, cp_msg, strlen(cp_msg) + 1, format, formatlen, NULL) == -1)
+ if (gg_send_packet(sess, GG_SEND_MSG80, &s80, sizeof(s80), + utf_html_msg, strlen(utf_html_msg) + 1, cp_msg, + strlen(cp_msg) + 1, format, formatlen, NULL) == -1) @@ -1714,9 +1780,12 @@
int gg_send_message(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message)
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message(%p, %d, %u, %p)\n", sess, msgclass, recipient, message);
- return gg_send_message_common(sess, msgclass, 1, &recipient, message, (const unsigned char*) "\x02\x06\x00\x00\x00\x08\x00\x00\x00", 9, NULL);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message(%p, %d, " + "%u, %p)\n", sess, msgclass, recipient, message); + return gg_send_message_common(sess, msgclass, 1, &recipient, message, + (const unsigned char*)"\x02\x06\x00\x00\x00\x08\x00\x00\x00", @@ -1736,9 +1805,13 @@
-int gg_send_message_richtext(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, const unsigned char *format, int formatlen)
+int gg_send_message_richtext(struct gg_session *sess, int msgclass, + uin_t recipient, const unsigned char *message, + const unsigned char *format, int formatlen) - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_richtext(%p, %d, %u, %p, %p, %d);\n", sess, msgclass, recipient, message, format, formatlen);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_richtext(" + "%p, %d, %u, %p, %p, %d);\n", sess, msgclass, recipient, + message, format, formatlen); return gg_send_message_common(sess, msgclass, 1, &recipient, message, format, formatlen, NULL);
@@ -1760,7 +1833,8 @@
int gg_send_message_html(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *html_message)
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_html(%p, %d, %u, %p);\n", sess, msgclass, recipient, html_message);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_html(%p, " + "%d, %u, %p);\n", sess, msgclass, recipient, html_message); return gg_send_message_common(sess, msgclass, 1, &recipient, NULL, NULL, 0, html_message);
@@ -1781,11 +1855,17 @@
-int gg_send_message_confer(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message)
+int gg_send_message_confer(struct gg_session *sess, int msgclass, + int recipients_count, uin_t *recipients, const unsigned char *message) - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_confer(%p, %d, %d, %p, %p);\n", sess, msgclass, recipients_count, recipients, message);
- return gg_send_message_common(sess, msgclass, recipients_count, recipients, message, (const unsigned char*) "\x02\x06\x00\x00\x00\x08\x00\x00\x00", 9, NULL);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_confer(" + "%p, %d, %d, %p, %p);\n", sess, msgclass, recipients_count, + return gg_send_message_common(sess, msgclass, recipients_count, + (const unsigned char*)"\x02\x06\x00\x00\x00\x08\x00\x00\x00", @@ -1806,9 +1886,14 @@
-int gg_send_message_confer_richtext(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *message, const unsigned char *format, int formatlen)
+int gg_send_message_confer_richtext(struct gg_session *sess, int msgclass, + int recipients_count, uin_t *recipients, const unsigned char *message, + const unsigned char *format, int formatlen) - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_confer_richtext(%p, %d, %d, %p, %p, %p, %d);\n", sess, msgclass, recipients_count, recipients, message, format, formatlen);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, + "** gg_send_message_confer_richtext(%p, %d, %d, %p, %p, %p, " + "%d);\n", sess, msgclass, recipients_count, recipients, message, return gg_send_message_common(sess, msgclass, recipients_count, recipients, message, format, formatlen, NULL);
@@ -1829,9 +1914,13 @@
-int gg_send_message_confer_html(struct gg_session *sess, int msgclass, int recipients_count, uin_t *recipients, const unsigned char *html_message)
+int gg_send_message_confer_html(struct gg_session *sess, int msgclass, + int recipients_count, uin_t *recipients, + const unsigned char *html_message) - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_confer_html(%p, %d, %d, %p, %p);\n", sess, msgclass, recipients_count, recipients, html_message);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, + "** gg_send_message_confer_html(%p, %d, %d, %p, %p);\n", sess, + msgclass, recipients_count, recipients, html_message); return gg_send_message_common(sess, msgclass, recipients_count, recipients, NULL, NULL, 0, html_message);
@@ -1853,11 +1942,13 @@
-int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, const unsigned char *message, int message_len)
+int gg_send_message_ctcp(struct gg_session *sess, int msgclass, uin_t recipient, + const unsigned char *message, int message_len) - gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_ctcp(%p, %d, %u, ...);\n", sess, msgclass, recipient);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_send_message_ctcp(%p, " + "%d, %u, ...);\n", sess, msgclass, recipient); @@ -1900,7 +1991,8 @@
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_image_request(%p, %d, %u, 0x%.4x);\n", sess, recipient, size, crc32);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_image_request(%p, %d, " + "%u, 0x%.4x);\n", sess, recipient, size, crc32); @@ -1932,13 +2024,14 @@
- gg_debug_session(sess, GG_DEBUG_MISC, "// gg_image_request() not enough memory for image queue\n");
+ gg_debug_session(sess, GG_DEBUG_MISC, + "// gg_image_request() not enough memory for "
gg_debug_session(sess, GG_DEBUG_MISC, "// gg_image_request() not enough memory for image\n");
@@ -1956,8 +2049,7 @@
struct gg_image_queue *qq;
- for (qq = sess->images; qq->next; qq = qq->next)
+ for (qq = sess->images; qq->next; qq = qq->next); @@ -1987,7 +2079,8 @@
- gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_image_reply(%p, %d, \"%s\", %p, %d);\n", sess, recipient, filename, image, size);
+ gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_image_reply(%p, %d, " + "\"%s\", %p, %d);\n", sess, recipient, filename, image, size); if (!sess || !filename || !image) {
@@ -2070,7 +2163,7 @@
gg_tvbuilder_write_uint8(tvb,
(types == NULL) ? GG_USER_NORMAL : types[i]);
- /* Oryginalny klient wysyła maksymalnie 2048 bajtów
+ /* Oryginalny klient wysyła maksymalnie 2048 bajtów * danych w każdym pakiecie tego typu.
if (gg_tvbuilder_get_size(tvb) > 2048) {
@@ -2081,7 +2174,8 @@
if (!gg_tvbuilder_send(tvb, (i < count) ?
- GG_NOTIFY105_FIRST : GG_NOTIFY105_LAST)) {
+ GG_NOTIFY105_FIRST : GG_NOTIFY105_LAST)) @@ -2112,8 +2206,6 @@
int gg_notify_ex(struct gg_session *sess, uin_t *userlist, char *types, int count)
gg_debug_session(sess, GG_DEBUG_FUNCTION, "** gg_notify_ex(%p, %p, %p, %d);\n", sess, userlist, types, count);
@@ -2148,12 +2240,12 @@
if (!(n = (struct gg_notify*) malloc(sizeof(*n) * part_count)))
- for (u = userlist, t = types, i = 0; i < part_count; u++, t++, i++) {
- n[i].uin = gg_fix32(*u);
+ for (i = 0; i < part_count; i++) { + n[i].uin = gg_fix32(userlist[i]); n[i].dunno1 = GG_USER_NORMAL;
+ n[i].dunno1 = types[i]; if (gg_send_packet(sess, packet_type, n, sizeof(*n) * part_count, NULL) == -1) {
@@ -2411,7 +2503,8 @@
-int gg_userlist100_request(struct gg_session *sess, char type, unsigned int version, char format_type, const char *request)
+int gg_userlist100_request(struct gg_session *sess, char type, + unsigned int version, char format_type, const char *request) struct gg_userlist100_request pkt;
@@ -2550,8 +2643,11 @@
if (!gg_required_proto(gs, GG_PROTOCOL_VERSION_110))
- if (participants_count == 0 || participants_count >= ~0 / sizeof(struct gg_chat_participant))
+ if (participants_count == 0 || participants_count >= + ~(unsigned int)0 / sizeof(struct gg_chat_participant)) participants_list_size = sizeof(struct gg_chat_participant) *
@@ -2564,8 +2660,7 @@
pkt.participants_count = gg_fix32(participants_count);
- for (i = 0; i < participants_count; i++)
+ for (i = 0; i < participants_count; i++) { participants_list[i].uin = gg_fix32(participants[i]);
participants_list[i].dummy = gg_fix32(0x1e);
@@ -2692,7 +2787,12 @@
sess->check = GG_CHECK_READ;
sess->state = GG_STATE_ERROR;
- send(pipes[0], &dummy, sizeof(dummy), 0);
+ if (send(pipes[0], &dummy, sizeof(dummy), 0) != sizeof(dummy)) { + gg_debug(GG_DEBUG_MISC, "// gg_socket_manager_error() unable to" + " send via pipe (errno=%d, %s)\n", errno, --- a/libpurple/protocols/gg/lib/pubdir.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/pubdir.c Mon Mar 24 20:01:11 2014 -0400
@@ -49,7 +49,8 @@
-struct gg_http *gg_register3(const char *email, const char *password, const char *tokenid, const char *tokenval, int async)
+struct gg_http *gg_register3(const char *email, const char *password, + const char *tokenid, const char *tokenval, int async) char *__pwd, *__email, *__tokenid, *__tokenval, *form, *query;
@@ -107,7 +108,9 @@
- if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) {
+ if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, + "POST", "/appsvc/fmregister3.asp", query))) gg_debug(GG_DEBUG_MISC, "=> register, gg_http_connect() failed mysteriously\n");
@@ -119,10 +122,10 @@
h->callback = gg_pubdir_watch_fd;
h->destroy = gg_pubdir_free;
@@ -190,7 +193,7 @@
__pwd = gg_saprintf("%d", rand());
__fmpwd = gg_urlencode(password);
__tokenid = gg_urlencode(tokenid);
@@ -205,7 +208,10 @@
- form = gg_saprintf("fmnumber=%d&fmpwd=%s&delete=1&pwd=%s&email=deletedaccount@gadu-gadu.pl&tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __tokenid, __tokenval, gg_http_hash("ss", "deletedaccount@gadu-gadu.pl", __pwd));
+ form = gg_saprintf("fmnumber=%d&fmpwd=%s&delete=1&pwd=%s&" + "email=deletedaccount@gadu-gadu.pl&tokenid=%s&tokenval=%s&" + "code=%u", uin, __fmpwd, __pwd, __tokenid, __tokenval, + gg_http_hash("ss", "deletedaccount@gadu-gadu.pl", __pwd)); @@ -236,7 +242,9 @@
- if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) {
+ if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, + "POST", "/appsvc/fmregister3.asp", query))) gg_debug(GG_DEBUG_MISC, "=> unregister, gg_http_connect() failed mysteriously\n");
@@ -248,10 +256,10 @@
h->callback = gg_pubdir_watch_fd;
h->destroy = gg_pubdir_free;
@@ -311,7 +319,9 @@
-struct gg_http *gg_change_passwd4(uin_t uin, const char *email, const char *passwd, const char *newpasswd, const char *tokenid, const char *tokenval, int async)
+struct gg_http *gg_change_passwd4(uin_t uin, const char *email, + const char *passwd, const char *newpasswd, const char *tokenid, + const char *tokenval, int async) char *form, *query, *__email, *__fmpwd, *__pwd, *__tokenid, *__tokenval;
@@ -321,7 +331,7 @@
__fmpwd = gg_urlencode(passwd);
__pwd = gg_urlencode(newpasswd);
__email = gg_urlencode(email);
@@ -337,8 +347,11 @@
- if (!(form = gg_saprintf("fmnumber=%d&fmpwd=%s&pwd=%s&email=%s&tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __email, __tokenid, __tokenval, gg_http_hash("ss", email, newpasswd)))) {
+ if (!(form = gg_saprintf("fmnumber=%d&fmpwd=%s&pwd=%s&email=%s&" + "tokenid=%s&tokenval=%s&code=%u", uin, __fmpwd, __pwd, __email, + __tokenid, __tokenval, gg_http_hash("ss", email, newpasswd)))) gg_debug(GG_DEBUG_MISC, "=> change, not enough memory for form fields\n");
@@ -348,13 +361,13 @@
gg_debug(GG_DEBUG_MISC, "=> change, %s\n", form);
@@ -374,7 +387,9 @@
- if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, "POST", "/appsvc/fmregister3.asp", query))) {
+ if (!(h = gg_http_connect(GG_REGISTER_HOST, GG_REGISTER_PORT, async, + "POST", "/appsvc/fmregister3.asp", query))) gg_debug(GG_DEBUG_MISC, "=> change, gg_http_connect() failed mysteriously\n");
@@ -457,7 +472,7 @@
__tokenid = gg_urlencode(tokenid);
__tokenval = gg_urlencode(tokenval);
__email = gg_urlencode(email);
@@ -470,7 +485,10 @@
- if (!(form = gg_saprintf("userid=%d&code=%u&tokenid=%s&tokenval=%s&email=%s", uin, gg_http_hash("u", uin), __tokenid, __tokenval, __email))) {
+ if (!(form = gg_saprintf("userid=%d&code=%u&tokenid=%s&tokenval=%s&" + "email=%s", uin, gg_http_hash("u", uin), __tokenid, __tokenval, gg_debug(GG_DEBUG_MISC, "=> remind, not enough memory for form fields\n");
@@ -481,7 +499,7 @@
gg_debug(GG_DEBUG_MISC, "=> remind, %s\n", form);
@@ -585,7 +603,7 @@
if (h->state != GG_STATE_PARSING) {
if (gg_http_watch_fd(h) == -1) {
gg_debug(GG_DEBUG_MISC, "=> pubdir, http failure\n");
@@ -596,9 +614,9 @@
if (h->state != GG_STATE_PARSING)
h->state = GG_STATE_DONE;
if (!(h->data = p = malloc(sizeof(struct gg_pubdir)))) {
gg_debug(GG_DEBUG_MISC, "=> pubdir, not enough memory for results\n");
@@ -606,7 +624,7 @@
gg_debug(GG_DEBUG_MISC, "=> pubdir, let's parse \"%s\"\n", h->body);
if ((tmp = strstr(h->body, "Tokens okregisterreply_packet.reg.dwUserId="))) {
@@ -646,7 +664,7 @@
@@ -684,10 +702,10 @@
h->callback = gg_token_watch_fd;
h->destroy = gg_token_free;
@@ -716,7 +734,7 @@
if (h->state != GG_STATE_PARSING) {
if (gg_http_watch_fd(h) == -1) {
gg_debug(GG_DEBUG_MISC, "=> token, http failure\n");
@@ -727,7 +745,7 @@
if (h->state != GG_STATE_PARSING)
/* jeśli h->data jest puste, to ściągaliśmy tokenid i url do niego,
* ale jeśli coś tam jest, to znaczy, że mamy drugi etap polegający
* na pobieraniu tokenu. */
@@ -737,15 +755,18 @@
gg_debug(GG_DEBUG_MISC, "=> token body \"%s\"\n", h->body);
- if (h->body && (!(url = malloc(strlen(h->body))) || !(tokenid = malloc(strlen(h->body))))) {
+ results_len = h->body ? strlen(h->body) : 0; + if (h->body && (!(url = malloc(results_len)) || !(tokenid = malloc(results_len)))) { gg_debug(GG_DEBUG_MISC, "=> token, not enough memory for results\n");
if (!h->body || sscanf(h->body, "%d %d %d\r\n%s\r\n%s", &width, &height, &length, tokenid, url) != 5) {
gg_debug(GG_DEBUG_MISC, "=> token, parsing failed\n");
@@ -753,7 +774,7 @@
/* dostaliśmy tokenid i wszystkie niezbędne informacje,
* więc pobierzmy obrazek z tokenem */
@@ -789,7 +810,7 @@
if (!(h2 = gg_http_connect(host, GG_REGISTER_PORT, h->async, "GET", path, headers))) {
gg_debug(GG_DEBUG_MISC, "=> token, gg_http_connect() failed mysteriously\n");
@@ -813,7 +834,7 @@
h->callback = gg_token_watch_fd;
h->destroy = gg_token_free;
@@ -831,7 +852,7 @@
/* obrazek mamy w h->body */
h->state = GG_STATE_DONE;
@@ -851,7 +872,7 @@
--- a/libpurple/protocols/gg/lib/sha1.c Tue Mar 04 23:12:23 2014 -0800
+++ b/libpurple/protocols/gg/lib/sha1.c Mon Mar 24 20:01:11 2014 -0400
@@ -88,20 +88,22 @@
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
#ifndef GG_CONFIG_BIGENDIAN
-#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
- |(rol(block->l[i],8)&0x00FF00FF))
+#define blk0(i) (block->l[i] = (rol(block->l[i], 24) & 0xFF00FF00) \ + |(rol(block->l[i], 8) & 0x00FF00FF)) #define blk0(i) block->l[i]
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
- ^block->l[(i+2)&15]^block->l[i&15],1))
+ ^block->l[(i+2)&15]^block->l[i&15], 1)) /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
+/* style:comma:start-ignore */ #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
#define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
#define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
#define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
+/* style:comma:end-ignore */ /* Hash a single 512-bit block. This is the core of the algorithm. */
@@ -124,6 +126,7 @@
/* 4 rounds of 20 operations each. Loop unrolled. */
+ /* style:comma:start-ignore */ R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
@@ -144,6 +147,7 @@
R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
+ /* style:comma:end-ignore */ /* Add the working vars back into context.state[] */
@@ -240,7 +244,7 @@
* \param result Bufor na wynik funkcji skrótu (20 bajtów)
int gg_login_hash_sha1_2(const char *password, uint32_t seed, uint8_t *result)
@@ -256,7 +260,7 @@
if (!SHA1_Update(&ctx, (uint8_t*) &seed, 4))
if (!SHA1_Final(result, &ctx))
@@ -264,7 +268,7 @@
/* Zwolnij zasoby. Tylko GnuTLS przyjęłoby NULL zamiast result, więc przekaż result. */
- SHA1_Final(result, &ctx);
+ (void)SHA1_Final(result, &ctx); @@ -296,7 +300,7 @@
res = read(fd, buf, chunk_len);
if (res == -1 && errno != EINTR)
@@ -316,7 +320,7 @@
* \internal Liczy skrót SHA1 z pliku.
* Dla plików poniżej 10MB liczony jest skrót z całego pliku, dla plików
* powyżej 10MB liczy się 9 jednomegabajtowych fragmentów.
--- a/pidgin/gtkdialogs.c Tue Mar 04 23:12:23 2014 -0800
+++ b/pidgin/gtkdialogs.c Mon Mar 24 20:01:11 2014 -0400
@@ -206,6 +206,7 @@
{N_("Kurdish"), "ku", "Erdal Ronahi", "erdal.ronahi@gmail.com"},
{N_("Kurdish"), "ku", "Rizoyê Xerzî", "rizoxerzi@hotmail.com"},
{N_("Lithuanian"), "lt", "Algimantas Margevičius", "margevicius.algimantas@gmail.com"},
+ {N_("Latvian"), "lv", "Rudolfs Mazurs", "rudolfs.mazurs@gmail.com"}, {N_("Maithili"), "mai", "Sangeeta Kumari", "sangeeta_0975@yahoo.com"},
{N_("Maithili"), "mai", "Rajesh Ranjan", "rajeshkajha@yahoo.com"},
{N_("Meadow Mari"), "mhr", "David Preece", "davidpreece1@gmail.com"},
@@ -220,7 +221,7 @@
{N_("Nepali"), "ne", "Shyam Krishna Bal", NULL},
{N_("Dutch, Flemish"), "nl", "Gideon van Melle", "translations@gvmelle.com"},
{N_("Norwegian Nynorsk"), "nn", "Yngve Spjeld Landro", "l10n@landro.net"},
- {N_("Occitan"), "oc", "Yannig Marchegay", "yannig@marchegay.org"},
+ {N_("Occitan"), "oc", "Cédric Valmary", "cvalmary@yahoo.fr"}, {N_("Oriya"), "or", "Manoj Kumar Giri", "giri.manojkr@gmail.com"},
{N_("Punjabi"), "pa", "Amanpreet Singh Alam", "aalam@users.sf.net"},
{N_("Polish"), "pl", "Piotr Drąg", "piotrdrag@gmail.com"},
@@ -244,6 +245,7 @@
{N_("Tamil"), "ta", "Viveka Nathan K", "vivekanathan@users.sourceforge.net"},
{N_("Telugu"), "te", "Krishnababu Krottapalli", "krottapalli@ymail.com"},
{N_("Thai"), "th", "Isriya Paireepairit", "markpeak@gmail.com"},
+ {N_("Tatar"), "tt", "ILDAR Valeev", "v_ildar@bk.ru"}, {N_("Ukranian"), "uk", "Oleksandr Kovalenko", "alx.kovalenko@gmail.com"},
{N_("Urdu"), "ur", "RKVS Raman", "rkvsraman@gmail.com"},
{N_("Vietnamese"), "vi", "Nguyễn Vũ Hưng", "vuhung16plus@gmail.com"},
@@ -307,6 +309,7 @@
{N_("Bokmål Norwegian"), "nb", "Petter Johan Olsen", NULL},
{N_("Bokmål Norwegian"), "nb", "Espen Stefansen", "espenas@gmail.com"},
{N_("Dutch, Flemish"), "nl", "Vincent van Adrighem", "V.vanAdrighem@dirck.mine.nu"},
+ {N_("Occitan"), "oc", "Yannig Marchegay", "yannig@marchegay.org"}, {N_("Polish"), "pl", "Krzysztof Foltman", "krzysztof@foltman.com"},
{N_("Polish"), "pl", "Paweł Godlewski", "pawel@bajk.pl"},
{N_("Polish"), "pl", "Piotr Makowski", NULL},