After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 730376 - camel: Avoid an unlikely division by zero failure
camel: Avoid an unlikely division by zero failure
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: Evolution Shell Maintainers Team
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2014-05-19 13:40 UTC by Philip Withnall
Modified: 2015-05-11 23:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
camel: Avoid an unlikely division by zero failure (982 bytes, patch)
2014-05-19 13:40 UTC, Philip Withnall
reviewed Details | Review
camel: Avoid an unlikely division by zero on a race condition (1.36 KB, patch)
2014-05-19 13:48 UTC, Philip Withnall
committed Details | Review
camel: Avoid an unlikely division by zero failure (1.29 KB, patch)
2014-05-20 10:49 UTC, Philip Withnall
committed Details | Review
camel: Avoid an unlikely division by zero on a race condition (1.37 KB, patch)
2015-05-10 10:27 UTC, Philip Withnall
committed Details | Review

Description Philip Withnall 2014-05-19 13:40:15 UTC
Patch attached.
Comment 1 Philip Withnall 2014-05-19 13:40:16 UTC
Created attachment 276775 [details] [review]
camel: Avoid an unlikely division by zero failure

Coverity issue: #1061270
Comment 2 Philip Withnall 2014-05-19 13:48:15 UTC
Created attachment 276776 [details] [review]
camel: Avoid an unlikely division by zero on a race condition

This is a subtle and really unlikely TOCTTOU race which Coverity found.
Fix the potential division by zero which results from it.

Coverity issue: #1061271
Comment 3 Milan Crha 2014-05-19 16:31:30 UTC
Review of attachment 276775 [details] [review]:

Does this change really help Covscan to be happy with it? As goffset is signed and the function can eventually return -1, then you get division by 0 too. There might be some size = 1; of 'else' of the fstat() call, thus the added MAX will always make it >0.
Comment 4 Milan Crha 2014-05-19 16:32:38 UTC
Review of attachment 276776 [details] [review]:

This one if fine. Feel free to commit. Thanks.
Comment 5 Philip Withnall 2014-05-20 10:11:27 UTC
Comment on attachment 276776 [details] [review]
camel: Avoid an unlikely division by zero on a race condition

Attachment 276776 [details] pushed as 8fb4543 - camel: Avoid an unlikely division by zero on a race condition
Comment 6 Philip Withnall 2014-05-20 10:49:45 UTC
Created attachment 276840 [details] [review]
camel: Avoid an unlikely division by zero failure

Coverity issue: #1061270
Comment 7 Milan Crha 2014-05-21 12:11:23 UTC
Review of attachment 276840 [details] [review]:

Looks fine, please commit. Thanks.
Comment 8 Philip Withnall 2014-05-21 12:45:51 UTC
Attachment 276840 [details] pushed as d8685b1 - camel: Avoid an unlikely division by zero failure
Comment 9 Philip Withnall 2015-05-10 10:27:03 UTC
Created attachment 303177 [details] [review]
camel: Avoid an unlikely division by zero on a race condition

This is a subtle and really unlikely TOCTTOU race which Coverity found.
Fix the potential division by zero which results from it.

This fixes another instance of the original problem, fixed in commit
8fb4543.

Coverity issue: #1061271
Comment 10 Philip Withnall 2015-05-10 10:28:37 UTC
(In reply to Philip Withnall from comment #9)
> Created attachment 303177 [details] [review] [review]
> camel: Avoid an unlikely division by zero on a race condition
> 
> This is a subtle and really unlikely TOCTTOU race which Coverity found.
> Fix the potential division by zero which results from it.
> 
> This fixes another instance of the original problem, fixed in commit
> 8fb4543.
> 
> Coverity issue: #1061271

This patch fixes another instance of the same problem, in a different place in camel-maildir-summary.c, which I should have fixed the same time round. Attaching the patch here because it stems from the same Coverity issue (CID: #1061271).
Comment 11 Milan Crha 2015-05-11 16:01:41 UTC
Review of attachment 303177 [details] [review]:

Looks fine, feel free to commit it. I left up to you whether only to master or also to gnome-3-16.
Comment 12 Philip Withnall 2015-05-11 23:04:14 UTC
Attachment 303177 [details] pushed as cc95f45 - camel: Avoid an unlikely division by zero on a race condition
Comment 13 Philip Withnall 2015-05-11 23:07:52 UTC
(In reply to Milan Crha from comment #11)
> Review of attachment 303177 [details] [review] [review]:
> 
> Looks fine, feel free to commit it. I left up to you whether only to master
> or also to gnome-3-16.

Just pushed to master. It's not worth touching gnome-3-16 for this, since it's a very unlikely race to hit.