From f656d0a7223de1ff2b1327ec3158a162f72966d7 Mon Sep 17 00:00:00 2001 From: JFreegman Date: Sat, 4 Apr 2015 03:42:43 -0400 Subject: [PATCH 1/3] Update .travis.yml --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f8e3ddc..3da703b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,4 +44,9 @@ script: - make -j2 || make || exit 1 notifications: email: false - + + irc: + channels: + - "chat.freenode.net#tox-dev" + on_success: always + on_failure: always From 1a7eaeddba37082e69bbd21d84b26988e92dde2b Mon Sep 17 00:00:00 2001 From: Jfreegman Date: Sat, 4 Apr 2015 21:15:34 -0400 Subject: [PATCH 2/3] fix a few avatar bugs --- src/avatars.c | 23 +++++++++-------------- src/avatars.h | 2 ++ src/global_commands.c | 4 +++- src/help.c | 2 +- src/toxic.c | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/avatars.c b/src/avatars.c index fb7007d..8dfa302 100644 --- a/src/avatars.c +++ b/src/avatars.c @@ -27,6 +27,7 @@ #include "misc_tools.h" #include "file_transfers.h" #include "friendlist.h" +#include "avatars.h" extern FriendsList Friends; @@ -36,7 +37,6 @@ static struct Avatar { char path[PATH_MAX + 1]; size_t path_len; off_t size; - bool is_set; } Avatar; @@ -55,8 +55,7 @@ int avatar_send(Tox *m, uint32_t friendnum) TOX_ERR_FILE_SEND err; uint32_t filenum = tox_file_send(m, friendnum, TOX_FILE_KIND_AVATAR, (size_t) Avatar.size, NULL, (uint8_t *) Avatar.name, Avatar.name_len, &err); - - if (!Avatar.is_set) + if (Avatar.size == 0) return 0; if (err != TOX_ERR_FILE_SEND_OK) { @@ -74,14 +73,8 @@ int avatar_send(Tox *m, uint32_t friendnum) if (ft->file == NULL) return -1; - ft->file_size = Avatar.size; - - if (ft->file_size == 0) { - fclose(ft->file); - return -1; - } - memcpy(ft->file_name, Avatar.name, Avatar.name_len + 1); + ft->file_size = Avatar.size; ft->state = FILE_TRANSFER_PENDING; ft->filenum = filenum; ft->friendnum = friendnum; @@ -109,8 +102,6 @@ static void avatar_send_all(Tox *m) */ int avatar_set(Tox *m, const char *path, size_t path_len) { - avatar_clear(); - if (path_len == 0 || path_len >= sizeof(Avatar.path)) return -1; @@ -128,12 +119,16 @@ int avatar_set(Tox *m, const char *path, size_t path_len) fclose(fp); + off_t size = file_size(path); + + if (size == 0 || size > MAX_AVATAR_FILE_SIZE) + return -1; + get_file_name(Avatar.name, sizeof(Avatar.name), path); Avatar.name_len = strlen(Avatar.name); memcpy(Avatar.path, path, sizeof(Avatar.path)); Avatar.path_len = path_len; - Avatar.size = file_size(path); - Avatar.is_set = 1; + Avatar.size = size; avatar_send_all(m); diff --git a/src/avatars.h b/src/avatars.h index 4ef2c60..af3c4af 100644 --- a/src/avatars.h +++ b/src/avatars.h @@ -23,6 +23,8 @@ #ifndef AVATARS_H #define AVATARS_H +#define MAX_AVATAR_FILE_SIZE 65536 + /* Sends avatar to friendnum. * * Returns 0 on success. diff --git a/src/global_commands.c b/src/global_commands.c index 5d7c6b1..f5e6fd7 100644 --- a/src/global_commands.c +++ b/src/global_commands.c @@ -225,7 +225,9 @@ void cmd_avatar(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv)[ get_file_name(filename, sizeof(filename), path); if (avatar_set(m, path, len) == -1) { - line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "Failed to set avatar."); + line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, + "Failed to set avatar. Avatars must be in PNG format and may not exceed %d bytes.", + MAX_AVATAR_FILE_SIZE); return; } diff --git a/src/help.c b/src/help.c index f212deb..8989c11 100644 --- a/src/help.c +++ b/src/help.c @@ -144,7 +144,7 @@ static void help_draw_global(ToxWindow *self) wprintw(win, " /add : Add contact with optional message\n"); wprintw(win, " /accept : Accept friend request\n"); - wprintw(win, " /avatar : Set a personal avatar\n"); + wprintw(win, " /avatar : Set an avatar (leave path empty to unset)\n"); wprintw(win, " /decline : Decline friend request\n"); wprintw(win, " /requests : List pending friend requests\n"); wprintw(win, " /connect : Manually connect to a DHT node\n"); diff --git a/src/toxic.c b/src/toxic.c index 55f5a19..dd0ee09 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -123,8 +123,8 @@ void exit_toxic_success(Tox *m) { store_data(m, DATA_FILE); memset(&user_password, 0, sizeof(struct user_password)); - kill_all_windows(m); kill_all_file_transfers(m); + kill_all_windows(m); terminate_notify(); #ifdef AUDIO From 5a2c3412590b00551a78cf4a0f1669452b489a47 Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Mon, 6 Apr 2015 11:44:02 +0200 Subject: [PATCH 3/3] Makefile: try to fix Tox/toxic#307 @henriqueleng please test it and report back if it works for you. --- cfg/targets/install.mk | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cfg/targets/install.mk b/cfg/targets/install.mk index cdc0067..12050ff 100644 --- a/cfg/targets/install.mk +++ b/cfg/targets/install.mk @@ -13,7 +13,8 @@ install: $(BUILD_DIR)/toxic @for f in $(DATAFILES) ; do \ install -m 0644 $(MISC_DIR)/$$f $(abspath $(DESTDIR)/$(DATADIR)/$$f) ;\ file=$(abspath $(DESTDIR)/$(DATADIR)/$$f) ;\ - sed -i'' -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file ;\ + sed -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file > temp_file && \ + mv temp_file $$file ;\ done @mkdir -p $(abspath $(DESTDIR)/$(DATADIR))/sounds @for f in $(SNDFILES) ; do \ @@ -30,8 +31,10 @@ install: $(BUILD_DIR)/toxic file=$$section/$$f ;\ mkdir -p $$section ;\ install -m 0644 $(DOC_DIR)/$$f $$file ;\ - sed -i'' -e 's:__VERSION__:'$(VERSION)':g' $$file ;\ - sed -i'' -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file ;\ + sed -e 's:__VERSION__:'$(VERSION)':g' $$file > temp_file && \ + mv temp_file $$file ;\ + sed -e 's:__DATADIR__:'$(abspath $(DATADIR))':g' $$file > temp_file && \ + mv temp_file $$file ;\ gzip -f -9 $$file ;\ done