[metadata]
id = "FIO19-C"
type = "recommendation"
category = "FIO"
number = 19
title = "Do not use fseek() and ftell() to compute the size of a regular file"
description = """
Understanding the difference between text mode and binary mode is important when
using functions that operate on file streams. (SeeFIO14-C. Understand the
difference between text mode and binary mode with file streamsfor more
information.) Subclause 7.21.9.2 of the C Standard [ISO/IEC 9899:2011] specifies
the following behavior forfseek()when opening a binary file in binary mode: In
addition, footnote 268 of subclause 7.21.3 says:
"""
severity = "Low"
likelihood = "Unlikely"
priority = "P3"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 20, 2025"
[rules.cert_c.FIO19-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/FIO19-C.+Do+not+use+fseek%28%29+and+ftell%28%29+to+compute+the+size+of+a+regular+file"