fix: CWE-134 format string vulnerability and compiler flags audit #98
@@ -72,13 +72,13 @@ echo ""
|
||||
|
||||
KNOWN_RE=$(IFS="|"; echo "${REQUIRED_ATTRIBUTED[*]}")
|
||||
|
||||
# Find variadic declarations with a const char* parameter followed by ...)
|
||||
# Find variadic declarations with a const char* / gchar* parameter followed by ...)
|
||||
# that do NOT have a format attribute on the preceding line
|
||||
NEW_ISSUES=$(grep -B1 -rn --include="*.h" \
|
||||
'const char\s*\*.*,\s*\.\.\.)' "$DIR" 2>/dev/null \
|
||||
'const g\?char\s*\*.*,\s*\.\.\.)' "$DIR" 2>/dev/null \
|
||||
|
jabber.developer marked this conversation as resolved
Outdated
|
||||
| awk '
|
||||
/format\(printf|G_GNUC_PRINTF/ { skip=1; next }
|
||||
/const char.*,.*\.\.\.\)/ {
|
||||
/const g?char.*,.*\.\.\.\)/ {
|
||||
if (skip) { skip=0; next }
|
||||
print
|
||||
}
|
||||
|
||||
@@ -981,9 +981,7 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins)
|
||||
auto_gchar gchar* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int itemcount = g_list_length(wins);
|
||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", itemcount);
|
||||
} else if (itemcount > 0) {
|
||||
if (itemcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", itemcount);
|
||||
}
|
||||
|
jabber.developer marked this conversation as resolved
Outdated
jabber.developer
commented
It doesn't make sense to do it this way. Condition is still duplicated. Something like this would be more concise. It doesn't make sense to do it this way. Condition is still duplicated.
Something like this would be more concise.
```c
if (itemcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO))
```
jabber.developer2
commented
corrected corrected
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
@@ -994,9 +992,7 @@ _rosterwin_unsubscribed_header(ProfLayoutSplit* layout, GList* wins)
|
||||
unreadcount += chatwin->unread;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
if (unreadcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", unreadcount);
|
||||
} else if (unreadcount > 0) {
|
||||
if (unreadcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", unreadcount);
|
||||
}
|
||||
}
|
||||
@@ -1026,9 +1022,7 @@ _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSL
|
||||
auto_gchar gchar* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int itemcount = g_slist_length(contacts);
|
||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", itemcount);
|
||||
} else if (itemcount > 0) {
|
||||
if (itemcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", itemcount);
|
||||
}
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
@@ -1043,9 +1037,7 @@ _rosterwin_contacts_header(ProfLayoutSplit* layout, const char* const title, GSL
|
||||
}
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
if (unreadcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", unreadcount);
|
||||
} else if (unreadcount > 0) {
|
||||
if (unreadcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(header, " (%d)", unreadcount);
|
||||
}
|
||||
}
|
||||
@@ -1136,9 +1128,7 @@ _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs)
|
||||
auto_gchar gchar* countpref = prefs_get_string(PREF_ROSTER_COUNT);
|
||||
if (g_strcmp0(countpref, "items") == 0) {
|
||||
int itemcount = g_list_length(privs);
|
||||
if (itemcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(title_str, " (%d)", itemcount);
|
||||
} else if (itemcount > 0) {
|
||||
if (itemcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(title_str, " (%d)", itemcount);
|
||||
}
|
||||
} else if (g_strcmp0(countpref, "unread") == 0) {
|
||||
@@ -1149,9 +1139,7 @@ _rosterwin_private_header(ProfLayoutSplit* layout, GList* privs)
|
||||
unreadcount += privwin->unread;
|
||||
curr = g_list_next(curr);
|
||||
}
|
||||
if (unreadcount == 0 && prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(title_str, " (%d)", unreadcount);
|
||||
} else if (unreadcount > 0) {
|
||||
if (unreadcount != 0 || prefs_get_boolean(PREF_ROSTER_COUNT_ZERO)) {
|
||||
g_string_append_printf(title_str, " (%d)", unreadcount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -517,32 +517,29 @@ _omemo_receive_devicelist(xmpp_stanza_t* const stanza, void* const userdata)
|
||||
log_warning("[OMEMO] User %s has a non 'current' device item list: %s.", from, xmpp_stanza_get_id(first));
|
||||
item = first;
|
||||
} else {
|
||||
goto out;
|
||||
omemo_set_device_list(from, device_list);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
jabber.developer marked this conversation as resolved
Outdated
jabber.developer
commented
Again comment style issue. Also I do not see a point in this scope Again comment style issue. Also I do not see a point in this scope
jabber.developer2
commented
Refactored Refactored
|
||||
/* New scope to keep declarations after goto out above */
|
||||
{
|
||||
xmpp_stanza_t* list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
|
||||
if (!list) {
|
||||
return 1;
|
||||
xmpp_stanza_t* list = xmpp_stanza_get_child_by_ns(item, STANZA_NS_OMEMO);
|
||||
if (!list) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
xmpp_stanza_t* device;
|
||||
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
xmpp_stanza_t* device;
|
||||
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
|
||||
if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* id = xmpp_stanza_get_id(device);
|
||||
if (id != NULL) {
|
||||
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
|
||||
} else {
|
||||
log_error("[OMEMO] received device without ID");
|
||||
}
|
||||
const char* id = xmpp_stanza_get_id(device);
|
||||
if (id != NULL) {
|
||||
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
|
||||
} else {
|
||||
log_error("[OMEMO] received device without ID");
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
omemo_set_device_list(from, device_list);
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user
What about
gchar?added