ecryptfs-devel team mailing list archive
-
ecryptfs-devel team
-
Mailing list archive
-
Message #00003
Re: [PATCH] mount.ecryptfs_private/umount.ecryptfs_private counter
Mike-
You also mentioned some reservation with respect to the fscanf.
> rewind(fh);
> /* Read the count from file, default to 0 */
> if (fscanf(fh, "%d\n", &count) != 1) {
> count = 0;
> }
> /* Increment/decrement the counter */
> count += delta;
> if (count < 0) {
> /* Don't set a count less than 0 */
> count = 0;
> }
Note that:
* We're reading an int (%d); most problems with scanf are with
strings (%s)
* We check the return code of fscanf() and set count to
something reasonable in the event of an error
* And we check the value of the integer read
Based on some additional feedback from Jamie Strandboge, I'm going to
improve the file opening/creation code to handle
time-of-check/time-of-use race conditions that could be present between
the stat() and the open() calls.
I will post another patch here soon.
:-Dustin
Attachment:
signature.asc
Description: This is a digitally signed message part
References