[metadata]
id = "FIO08-C"
type = "recommendation"
category = "FIO"
number = 8
title = "Take care when calling remove() on an open file"
description = """
Invokingremove()on an open file isimplementation-defined. Removing an open file
is sometimes recommended to hide the names of temporary files that may be prone
to attack. (SeeFIO21-C. Do not create temporary files in shared directories.) In
cases requiring the removal of an open file, a more strongly defined function,
such as the POSIXunlink()function, should be considered. To be strictly
conforming and portable,remove()shouldnotbe called on an open file. This
noncompliant code example shows a case where a file is removed while it is still
open:
"""
severity = "Medium"
likelihood = "Probable"
priority = "P4"
level = "L3"
cert_version = "2016 Edition (Wiki)"
last_modified = "May 20, 2025"
[rules.cert_c.FIO08-C]
enabled = true
[references]
wiki = "https://wiki.sei.cmu.edu/confluence/display/c/FIO08-C.+Take+care+when+calling+remove%28%29+on+an+open+file"