Skip to content

Commit

Permalink
Fix problems found when fixing docker (#575)
Browse files Browse the repository at this point in the history
* Require at least glib-2.36 (from 03/2013) to remove deprecated g_type_init()

* Fix empty continuation line in Dockerfile

* Require at least libmicrohttpd 0.9.25 (from 09/2012) to replace deprecated MHD_create_response_from_data()

* fix versioncheck libmicrohttpd

* Missing char for null-terminator in print_v6addrs()

* safe_asprintf to fix /proc/subdir bufferoverflows

There is no max length of /proc/subdir, increasing the value of /proc/sys/kernel/pid_max is one way this can happen

* Fix conversion constant c++ string to variable char array

* Fix strncpy using unrelated MPD_BUFFER_MAX_LENGTH

* Use strncpy instead of strcpy in eve.cc

* Use strncpy instead of strcpy in libmpdclient.cc

* move safe_asprintf back and use ostreams in proc.cc to make sonarcloud happy
  • Loading branch information
ngaro authored and brndnmtthws committed Aug 7, 2018
1 parent a78a750 commit 4d5db32
Show file tree
Hide file tree
Showing 10 changed files with 133 additions and 147 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ RUN sh -c 'if [ "$X11" = "yes" ] ; then \
libxml2-dev \
tolua++ \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /conky \
&& rm -rf /conky

CMD conky
11 changes: 4 additions & 7 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,9 @@ if(BUILD_IPV6)
endif(BUILD_IPV6)

if(BUILD_HTTP)
find_file(HTTP_H_ microhttpd.h)
#I'm not using check_include_files because microhttpd.h seems to need a lot of different headers and i'm not sure which...
if(NOT HTTP_H_)
message(FATAL_ERROR "Unable to find libmicrohttpd")
endif(NOT HTTP_H_)
set(conky_libs ${conky_libs} -lmicrohttpd)
pkg_check_modules(MICROHTTPD REQUIRED libmicrohttpd>=0.9.25)
set(conky_libs ${conky_libs} ${MICROHTTPD_LIBRARIES})
set(conky_includes ${conky_includes} ${MICROHTTPD_INCLUDE_DIRS})
endif(BUILD_HTTP)

if(BUILD_NCURSES)
Expand Down Expand Up @@ -435,7 +432,7 @@ endif(BUILD_PULSEAUDIO)

# Common libraries
if(WANT_GLIB)
pkg_check_modules(GLIB REQUIRED glib-2.0)
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.36)
set(conky_libs ${conky_libs} ${GLIB_LIBRARIES})
set(conky_includes ${conky_includes} ${GLIB_INCLUDE_DIRS})
endif(WANT_GLIB)
Expand Down
1 change: 0 additions & 1 deletion lua/rsvg.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ RsvgHandle *rsvg_handle_new_from_file (const char * file_name, GError ** error);
int rsvg_handle_render_cairo (RsvgHandle * handle, cairo_t * cr);
int rsvg_handle_render_cairo_sub (RsvgHandle * handle, cairo_t * cr, const char *id);

void g_type_init(void);
void g_object_unref(gpointer object);

RsvgHandle * rsvg_create_handle_from_file(const char *);
Expand Down
1 change: 0 additions & 1 deletion src/audacious.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ class audacious_cb : public conky::callback<aud_result> {
public:
audacious_cb(uint32_t period) : Base(period, false, Tuple()) {
#ifdef NEW_AUDACIOUS_FOUND
g_type_init();
DBusGConnection *connection = dbus_g_bus_get(DBUS_BUS_SESSION, nullptr);
if (!connection)
throw std::runtime_error("unable to establish dbus connection");
Expand Down
1 change: 0 additions & 1 deletion src/bmpx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ void update_bmpx() {
GHashTable *metadata;

if (connected == 0) {
g_type_init();
dbus_g_type_specialized_init();

bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error);
Expand Down
4 changes: 2 additions & 2 deletions src/conky.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ static conky::simple_config_setting<bool> http_refresh("http_refresh", false,
int sendanswer(void *cls, struct MHD_Connection *connection, const char *url,
const char *method, const char *version, const char *upload_data,
size_t *upload_data_size, void **con_cls) {
struct MHD_Response *response = MHD_create_response_from_data(
webpage.length(), (void *)webpage.c_str(), MHD_NO, MHD_NO);
struct MHD_Response *response = MHD_create_response_from_buffer(
webpage.length(), (void *)webpage.c_str(), MHD_RESPMEM_PERSISTENT);
int ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
MHD_destroy_response(response);
if (cls || url || method || version || upload_data || upload_data_size ||
Expand Down
20 changes: 10 additions & 10 deletions src/eve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream) {
}

int parseTrainingXml(char *data, Character *s) {
char *skill = "0";
char *level = "0";
char *ends = "";
char *cache = "";
char *isTraining = "0";
char *skill = nullptr;
char *level = nullptr;
char ends[20] = "";
char cache[20] = "";
char *isTraining = nullptr;
xmlNodePtr n;
xmlDocPtr doc = 0;
xmlNodePtr root = 0;
Expand All @@ -126,22 +126,22 @@ int parseTrainingXml(char *data, Character *s) {
if (!strcasecmp((const char *)c->name, "SkillInTraining")) {
isTraining = (char *)c->children->content;
} else if (!strcasecmp((const char *)c->name, "trainingEndTime")) {
ends = (char *)c->children->content;
strncpy(ends, (const char *)c->children->content, 20);
} else if (!strcasecmp((const char *)c->name, "trainingTypeID")) {
if (c->children->content) skill = (char *)c->children->content;
} else if (!strcasecmp((const char *)c->name, "trainingToLevel")) {
level = (char *)c->children->content;
}
}
} else if (!strcasecmp((const char *)n->name, "cachedUntil")) {
cache = (char *)n->children->content;
strncpy(cache, (const char*)n->children->content, 20);
}
}
}

s->isTraining = atoi(isTraining);
s->skill = atoi(skill);
s->level = atoi(level);
if(isTraining == nullptr) s->isTraining = 0; else s->isTraining = atoi(isTraining);
if(skill == nullptr) s->skill = 0; else s->skill = atoi(skill);
if(level == nullptr) s->level = 0; else s->level = atoi(level);

strptime(cache, "%Y-%m-%d %H:%M:%S", &cache_tm);
s->cache = cache_tm;
Expand Down
6 changes: 3 additions & 3 deletions src/libmpdclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1371,14 +1371,14 @@ void mpd_sendFindCommand(mpd_Connection *connection, int table,

void mpd_sendListCommand(mpd_Connection *connection, int table,
const char *arg1) {
char st[10];
char st[7];
int len;
char *string;

if (table == MPD_TABLE_ARTIST) {
strncpy(st, "artist", MPD_BUFFER_MAX_LENGTH);
strncpy(st, "artist", strlen("artist") + 1);
} else if (table == MPD_TABLE_ALBUM) {
strncpy(st, "album", MPD_BUFFER_MAX_LENGTH);
strncpy(st, "album", strlen("album") + 1);
} else {
connection->error = 1;
strncpy(connection->errorStr, "unknown table for list",
Expand Down
2 changes: 1 addition & 1 deletion src/net_stat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void print_v6addrs(struct text_object *obj, char *p, int p_max_size) {
}
// scope
if (ns->v6show_sc) {
char scopestr[3];
char scopestr[4];
sprintf(scopestr, "(%c)", current_v6->scope);
strncat(p, scopestr, p_max_size);
}
Expand Down
Loading

0 comments on commit 4d5db32

Please sign in to comment.