nurupo / ProjectTox-Qt-GUI

A cross-platform front end for ProjectTox Core library, written in C++11 with use of Qt5
GNU General Public License v3.0
342 stars 116 forks source link

Warnings during compilation #11

Closed kbabioch closed 11 years ago

kbabioch commented 11 years ago

There are a couple of warnings during compilation, which probably should be addressed. Especially the ones concerning the comparison of signed and unsigned integers might potentially be problematic when it comes to security.

I'm attaching the lines of the output of the compilation, which I think you should take another look at.

g++ -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -std=c++0x -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o settings.o ../src/Settings/settings.cpp ../src/Settings/settings.cpp:106:6: warning: unused parameter ‘parent’ [-Wunused-parameter] void Settings::executeSettingsDialog(QWidget* parent) ^

gcc -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o DHT.o ../submodules/ProjectTox-Core/core/DHT.c ../submodules/ProjectTox-Core/core/DHT.c: In function ‘sendnodes’: ../submodules/ProjectTox-Core/core/DHT.c:494:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(len != sizeof(ping_id) + num_nodes * sizeof(Node_format) + ENCRYPTION_PADDING) ^ ../submodules/ProjectTox-Core/core/DHT.c: In function ‘handle_sendnodes’: ../submodules/ProjectTox-Core/core/DHT.c:600:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(len != sizeof(ping_id) + num_nodes * sizeof(Node_format)) ^ ../submodules/ProjectTox-Core/core/DHT.c: In function ‘DHT_getfriendip’: ../submodules/ProjectTox-Core/core/DHT.c:664:5: warning: missing initializer for field ‘padding’ of ‘IP_Port’ [-Wmissing-field-initializers] IP_Port empty = {{{0}}, 0}; ^ In file included from ../submodules/ProjectTox-Core/core/Lossless_UDP.h:27:0, from ../submodules/ProjectTox-Core/core/net_crypto.h:27, from ../submodules/ProjectTox-Core/core/DHT.h:27, from ../submodules/ProjectTox-Core/core/DHT.c:24: ../submodules/ProjectTox-Core/core/network.h:82:14: note: ‘padding’ declared here uint16_t padding; ^ ../submodules/ProjectTox-Core/core/DHT.c: In function ‘route_tofriend’: ../submodules/ProjectTox-Core/core/DHT.c:811:91: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(sendpacket(friends_list[i].client_list[j].ip_port, packet, length) == length) ^ ../submodules/ProjectTox-Core/core/DHT.c: In function ‘routeone_tofriend’: ../submodules/ProjectTox-Core/core/DHT.c:839:56: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(sendpacket(ip_list[rand() % n], packet, length) == length) ^ ../submodules/ProjectTox-Core/core/DHT.c: In function ‘handle_NATping’: ../submodules/ProjectTox-Core/core/DHT.c:916:54: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] else if(route_packet(packet + 1, packet, length) == length) ^ ../submodules/ProjectTox-Core/core/DHT.c:885:63: warning: unused parameter ‘source’ [-Wunused-parameter] int handle_NATping(uint8_t * packet, uint32_t length, IP_Port source) ^ ../submodules/ProjectTox-Core/core/DHT.c: In function ‘punch_holes’: ../submodules/ProjectTox-Core/core/DHT.c:970:9: warning: missing initializer for field ‘padding’ of ‘IP_Port’ [-Wmissing-field-initializers] IP_Port pinging = {ip, htons(port)}; ^ In file included from ../submodules/ProjectTox-Core/core/Lossless_UDP.h:27:0, from ../submodules/ProjectTox-Core/core/net_crypto.h:27, from ../submodules/ProjectTox-Core/core/DHT.h:27, from ../submodules/ProjectTox-Core/core/DHT.c:24: ../submodules/ProjectTox-Core/core/network.h:82:14: note: ‘padding’ declared here uint16_t padding; ^ gcc -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o Lossless_UDP.o ../submodules/ProjectTox-Core/core/Lossless_UDP.c ../submodules/ProjectTox-Core/core/Lossless_UDP.c: In function ‘connection_ip’: ../submodules/ProjectTox-Core/core/Lossless_UDP.c:259:5: warning: missing initializer for field ‘padding’ of ‘IP_Port’ [-Wmissing-field-initializers] IP_Port zero = {{{0}}, 0}; ^ In file included from ../submodules/ProjectTox-Core/core/Lossless_UDP.h:27:0, from ../submodules/ProjectTox-Core/core/Lossless_UDP.c:26: ../submodules/ProjectTox-Core/core/network.h:82:14: note: ‘padding’ declared here uint16_t padding; ^ ../submodules/ProjectTox-Core/core/Lossless_UDP.c: In function ‘handle_SYNC2’: ../submodules/ProjectTox-Core/core/Lossless_UDP.c:483:88: warning: unused parameter ‘sent_packetnum’ [-Wunused-parameter] int handle_SYNC2(int connection_id, uint8_t counter, uint32_t recv_packetnum, uint32_t sent_packetnum) ^ gcc -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o Messenger.o ../submodules/ProjectTox-Core/core/Messenger.c ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘getclient_id’: ../submodules/ProjectTox-Core/core/Messenger.c:80:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friend_id >= numfriends || friend_id < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘m_delfriend’: ../submodules/ProjectTox-Core/core/Messenger.c:152:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendnumber >= numfriends || friendnumber < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘setfriendname’: ../submodules/ProjectTox-Core/core/Messenger.c:213:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendnumber >= numfriends || friendnumber < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘getname’: ../submodules/ProjectTox-Core/core/Messenger.c:244:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendnumber >= numfriends || friendnumber < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘m_get_userstatus_size’: ../submodules/ProjectTox-Core/core/Messenger.c:270:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendnumber >= numfriends || friendnumber < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘m_copy_userstatus’: ../submodules/ProjectTox-Core/core/Messenger.c:279:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendnumber >= numfriends || friendnumber < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘set_friend_userstatus’: ../submodules/ProjectTox-Core/core/Messenger.c:298:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendnumber >= numfriends || friendnumber < 0) ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘doFriends’: ../submodules/ProjectTox-Core/core/Messenger.c:375:58: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (friendlist[i].friend_request_id + 10 < unix_time()) { /I know this is hackish but it should work./ ^ ../submodules/ProjectTox-Core/core/Messenger.c: In function ‘Messenger_load’: ../submodules/ProjectTox-Core/core/Messenger.c:538:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (length == ~0) ^

gcc -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o network.o ../submodules/ProjectTox-Core/core/network.c ../submodules/ProjectTox-Core/core/network.c: In function ‘sendpacket’: ../submodules/ProjectTox-Core/core/network.c:66:5: warning: missing initializer for field ‘zeroes’ of ‘ADDR’ [-Wmissing-field-initializers] ADDR addr = {AF_INET, ip_port.port, ip_port.ip}; ^ In file included from ../submodules/ProjectTox-Core/core/network.c:24:0: ../submodules/ProjectTox-Core/core/network.h:89:13: note: ‘zeroes’ declared here uint8_t zeroes[8]; ^ ../submodules/ProjectTox-Core/core/network.c: In function ‘init_networking’: ../submodules/ProjectTox-Core/core/network.c:148:5: warning: missing initializer for field ‘zeroes’ of ‘ADDR’ [-Wmissing-field-initializers] ADDR addr = {AF_INET, htons(port), ip}; ^ In file included from ../submodules/ProjectTox-Core/core/network.c:24:0: ../submodules/ProjectTox-Core/core/network.h:89:13: note: ‘zeroes’ declared here uint8_t zeroes[8]; ^ gcc -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o friend_requests.o ../submodules/ProjectTox-Core/core/friend_requests.c ../submodules/ProjectTox-Core/core/friend_requests.c: In function ‘friendreq_handlepacket’: ../submodules/ProjectTox-Core/core/friend_requests.c:126:57: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if(route_packet(packet + 1, packet, length) == length) ^ ../submodules/ProjectTox-Core/core/friend_requests.c:104:71: warning: unused parameter ‘source’ [-Wunused-parameter] int friendreq_handlepacket(uint8_t * packet, uint32_t length, IP_Port source) ^ gcc -c -pipe -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -Wall -W -D_REENTRANT -fPIE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/usr/lib/qt/mkspecs/linux-g++ -I../projectfiles/QtCreator -I../src -I../submodules/ProjectTox-Core/core -I/usr/include/qt -I/usr/include/qt/QtWidgets -I/usr/include/qt/QtGui -I/usr/include/qt/QtCore -I. -I. -o LAN_discovery.o ../submodules/ProjectTox-Core/core/LAN_discovery.c ../submodules/ProjectTox-Core/core/LAN_discovery.c: In function ‘send_LANdiscovery’: ../submodules/ProjectTox-Core/core/LAN_discovery.c:69:5: warning: missing initializer for field ‘padding’ of ‘IP_Port’ [-Wmissing-field-initializers] IP_Port ip_port = {broadcast_ip(), port}; ^ In file included from ../submodules/ProjectTox-Core/core/Lossless_UDP.h:27:0, from ../submodules/ProjectTox-Core/core/net_crypto.h:27, from ../submodules/ProjectTox-Core/core/DHT.h:27, from ../submodules/ProjectTox-Core/core/LAN_discovery.h:29, from ../submodules/ProjectTox-Core/core/LAN_discovery.c:24: ../submodules/ProjectTox-Core/core/network.h:82:14: note: ‘padding’ declared here uint16_t padding; ^

nurupo commented 11 years ago

@johnpatcher please address Core's warnings to Core's repository.

The single warning that is related to GUI part is the /src/Settings/settings.cpp one, which will get fixed.

kbabioch commented 11 years ago

Ok, filed it again at the core repository. It can be found at 1.

nurupo commented 11 years ago

../src/Settings/settings.cpp:106:6: warning: unused parameter ‘parent’ [-Wunused-parameter] void Settings::executeSettingsDialog(QWidget* parent) ^

Fixed in https://github.com/nurupo/ProjectTox-Qt-GUI/commit/8255674b4d29064ad72fe0be678e6aae4e3595ea