Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence Coverity Scan false positive #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

monich
Copy link
Member

@monich monich commented Jan 27, 2025

236 GStrV*
237 gutil_strv_remove(
238     GStrV* sv,
239     const char* s,
240     gboolean remove_all)
241 {
       1. Condition sv, taking true branch.
       2. Condition s, taking true branch.
242     if (G_LIKELY(sv) && G_LIKELY(s)) {
       3. tainted_data_return: Called function gutil_strv_find(sv, s), and a possible return value may be less than zero.
       4. assign: Assigning: pos = gutil_strv_find(sv, s).
243         const int pos = gutil_strv_find(sv, s);
244
       5. Condition pos >= 0, taking true branch.
245         if (pos >= 0) {
246             guint len = gutil_strv_length(sv);
247
248             sv = gutil_strv_remove_impl(sv, pos, len, TRUE);
       6. Condition remove_all, taking true branch.
249             if (remove_all) {
250                 int i, l;
251
252                 len--;
253                 l = len - pos;
       7. Condition (i = gutil_strv_find_last_impl(sv + pos, s, l)) >= 0, taking true branch.
254                 while ((i = gutil_strv_find_last_impl(sv + pos, s, l)) >= 0) {
       8. overflow: The expression pos + i is considered to have possibly overflowed.
CID 1620096: (#1 of 1): Overflowed integer argument (INTEGER_OVERFLOW)
9. overflow_sink: pos + i, which might have overflowed, is passed to gutil_strv_remove_impl(sv, pos + i, len--, 1).[show details]
255                     sv = gutil_strv_remove_impl(sv, pos + i, len--, TRUE);
256                     l = i;
257                 }
258             }
259         }
260     }
261     return sv;

236 GStrV*
237 gutil_strv_remove(
238     GStrV* sv,
239     const char* s,
240     gboolean remove_all)
241 {
       1. Condition sv, taking true branch.
       2. Condition s, taking true branch.
242     if (G_LIKELY(sv) && G_LIKELY(s)) {
       3. tainted_data_return: Called function gutil_strv_find(sv, s), and a possible return value may be less than zero.
       4. assign: Assigning: pos = gutil_strv_find(sv, s).
243         const int pos = gutil_strv_find(sv, s);
244
       5. Condition pos >= 0, taking true branch.
245         if (pos >= 0) {
246             guint len = gutil_strv_length(sv);
247
248             sv = gutil_strv_remove_impl(sv, pos, len, TRUE);
       6. Condition remove_all, taking true branch.
249             if (remove_all) {
250                 int i, l;
251
252                 len--;
253                 l = len - pos;
       7. Condition (i = gutil_strv_find_last_impl(sv + pos, s, l)) >= 0, taking true branch.
254                 while ((i = gutil_strv_find_last_impl(sv + pos, s, l)) >= 0) {
       8. overflow: The expression pos + i is considered to have possibly overflowed.
CID 1620096: (sailfishos#1 of 1): Overflowed integer argument (INTEGER_OVERFLOW)
9. overflow_sink: pos + i, which might have overflowed, is passed to gutil_strv_remove_impl(sv, pos + i, len--, 1).[show details]
255                     sv = gutil_strv_remove_impl(sv, pos + i, len--, TRUE);
256                     l = i;
257                 }
258             }
259         }
260     }
261     return sv;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant