[CDRIVER-965] GridFS implementation must update md5 Created: 26/Oct/15  Updated: 18/Oct/16  Resolved: 18/Oct/16

Status: Closed
Project: C Driver
Component/s: GridFS
Affects Version/s: 1.2.0
Fix Version/s: 1.5.0

Type: Bug Priority: Minor - P4
Reporter: Kyle Suarez Assignee: Hannes Magnusson
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

All



 Description   

The C Driver must verify that the MD5 checksum is properly updated after a save or write.



 Comments   
Comment by Kyle Suarez [ 18/Oct/16 ]

Makes sense to me. Thanks Hannes!

Comment by Hannes Magnusson [ 18/Oct/16 ]

If this is actually a bug, then it has no material effect on any drivers.
Per the spec:
https://github.com/mongodb/specifications/blob/master/source/gridfs/gridfs-spec.rst

Comparing the MD5 in the files collection document to a re-computed MD5 allows detecting such errors and corruption. However, drivers now assume that the stored file is not corrupted, and applications that want to use the MD5 value to check for corruption must do so themselves.

Actually, further reading the spec:

Why store the MD5 checksum instead of creating the hash as-needed?
The MD5 checksum must be computed when a file is initially uploaded to GridFS, as this is the only time we are guaranteed to have the entire uncorrupted file. Computing it on-the-fly as a file is read from GridFS would ensure that our reads were successful, but guarantees nothing about the state of the file in the system. A successful check against the stored MD5 checksum guarantees that the stored file matches the original and no corruption has occurred.

And that is what we are doing. Only the mongoc_gridfs_file_save will calculate a md5 sum for the file and store it. Any other entry points, such as streaming, expect the user having created all the supporting mongoc_gridfs_file_opt_t and properly calculating the md5

Generated at Wed Feb 07 21:11:09 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.