{"$schema": "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json",
 "version": "2.1.0",
 "runs": [{"tool": {"driver": {"name": "GNU C23",
                               "fullName": "GNU C23 (GCC) version 16.1.1 20260703 (Red Hat 16.1.1-4) (x86_64-redhat-linux)",
                               "version": "16.1.1 20260703 (Red Hat 16.1.1-4)",
                               "informationUri": "https://gcc.gnu.org/gcc-16/",
                               "rules": [{"id": "-Wanalyzer-fd-leak",
                                          "helpUri": "https://gcc.gnu.org/onlinedocs/gcc-16.1.0/gcc/Static-Analyzer-Options.html#index-Wanalyzer-fd-leak"}]}},
           "taxonomies": [{"name": "CWE",
                           "version": "4.7",
                           "organization": "MITRE",
                           "shortDescription": {"text": "The MITRE Common Weakness Enumeration"},
                           "taxa": [{"id": "775",
                                     "helpUri": "https://cwe.mitre.org/data/definitions/775.html"}]}],
           "invocations": [{"arguments": ["/usr/libexec/gcc/x86_64-redhat-linux/16/cc1",
                                          "-quiet",
                                          "-I",
                                          "../src/include/",
                                          "-D",
                                          "_GNU_SOURCE",
                                          "-D",
                                          "__SANE_USERSPACE_TYPES__",
                                          "-D",
                                          "_LARGEFILE_SOURCE",
                                          "-D",
                                          "_FILE_OFFSET_BITS=64",
                                          "-D",
                                          "LIBURING_BUILD_TEST",
                                          "-include",
                                          "../config-host.h",
                                          "lfs-openat-write.c",
                                          "-quiet",
                                          "-dumpbase",
                                          "lfs-openat-write.c",
                                          "-dumpbase-ext",
                                          ".c",
                                          "-m64",
                                          "-mtune=generic",
                                          "-march=x86-64",
                                          "-mtls-dialect=gnu2",
                                          "-O2",
                                          "-Wno-unused-parameter",
                                          "-Wno-sign-compare",
                                          "-Wno-unknown-pragmas",
                                          "-flto=auto",
                                          "-ffat-lto-objects",
                                          "-fexceptions",
                                          "-fstack-protector-strong",
                                          "-fasynchronous-unwind-tables",
                                          "-fstack-clash-protection",
                                          "-fcf-protection=full",
                                          "-fno-omit-frame-pointer",
                                          "-fanalyzer",
                                          "-fdiagnostics-path-format=separate-events",
                                          "-fno-diagnostics-show-caret",
                                          "-fno-lto",
                                          "-fanalyzer-assume-nothrow",
                                          "-fdiagnostics-text-art-charset=none",
                                          "-fdiagnostics-set-output=sarif:file=/builddir/gcc-results/2876-e1kG.sarif",
                                          "-o",
                                          "/tmp/ccqE07LL.s"],
                            "workingDirectory": {"uri": "/builddir/build/BUILD/liburing-2.13-build/liburing-2.13/test"},
                            "startTimeUtc": "2026-08-03T18:01:47Z",
                            "executionSuccessful": true,
                            "toolExecutionNotifications": [],
                            "endTimeUtc": "2026-08-03T18:01:47Z"}],
           "originalUriBaseIds": {"PWD": {"uri": "file:///builddir/build/BUILD/liburing-2.13-build/liburing-2.13/test/"}},
           "artifacts": [{"location": {"uri": "lfs-openat-write.c",
                                       "uriBaseId": "PWD"},
                          "sourceLanguage": "c",
                          "contents": {"text": "/* SPDX-License-Identifier: MIT */\n\n#include <string.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <sys/types.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <errno.h>\n#include <sys/resource.h>\n#include <unistd.h>\n\n#include \"liburing.h\"\n#include \"helpers.h\"\n\nstatic const int RSIZE = 2;\nstatic const int OPEN_FLAGS = O_RDWR | O_CREAT | O_LARGEFILE;\nstatic const mode_t OPEN_MODE = S_IRUSR | S_IWUSR;\n\n#define DIE(...)\t\t\t\t\\\n\tdo {\t\t\t\t\t\\\n\t\tfprintf(stderr, __VA_ARGS__);\t\\\n\t\tabort();\t\t\t\\\n\t} while(0)\n\nstatic int do_write(struct io_uring *ring, int fd, off_t offset)\n{\n\tchar buf[] = \"some test write buf\";\n\tstruct io_uring_sqe *sqe;\n\tstruct io_uring_cqe *cqe;\n\tint res, ret;\n\n\tsqe = io_uring_get_sqe(ring);\n\tif (!sqe) {\n\t\tfprintf(stderr, \"failed to get sqe\\n\");\n\t\treturn 1;\n\t}\n\tio_uring_prep_write(sqe, fd, buf, sizeof(buf), offset);\n\n\tret = io_uring_submit(ring);\n\tif (ret < 0) {\n\t\tfprintf(stderr, \"failed to submit write: %s\\n\", strerror(-ret));\n\t\treturn 1;\n\t}\n\n\tret = io_uring_wait_cqe(ring, &cqe);\n\tif (ret < 0) {\n\t\tfprintf(stderr, \"wait_cqe failed: %s\\n\", strerror(-ret));\n\t\treturn 1;\n\t}\n\n\tres = cqe->res;\n\tio_uring_cqe_seen(ring, cqe);\n\tif (res < 0) {\n\t\tfprintf(stderr, \"write failed: %s\\n\", strerror(-res));\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}\n\nstatic int test_open_write(struct io_uring *ring, int dfd, const char *fn)\n{\n\tstruct io_uring_sqe *sqe;\n\tstruct io_uring_cqe *cqe;\n\tint ret, fd = -1;\n\n\tsqe = io_uring_get_sqe(ring);\n\tif (!sqe) {\n\t\tfprintf(stderr, \"failed to get sqe\\n\");\n\t\treturn 1;\n\t}\n\tio_uring_prep_openat(sqe, dfd, fn, OPEN_FLAGS, OPEN_MODE);\n\n\tret = io_uring_submit(ring);\n\tif (ret < 0) {\n\t\tfprintf(stderr, \"failed to submit openat: %s\\n\", strerror(-ret));\n\t\treturn 1;\n\t}\n\n\tret = io_uring_wait_cqe(ring, &cqe);\n\tif (ret < 0) {\n\t\tfprintf(stderr, \"wait_cqe failed: %s\\n\", strerror(-ret));\n\t\treturn 1;\n\t}\n\n\tfd = cqe->res;\n\tio_uring_cqe_seen(ring, cqe);\n\tif (fd < 0) {\n\t\tfprintf(stderr, \"openat failed: %s\\n\", strerror(-fd));\n\t\treturn 1;\n\t}\n\n\treturn do_write(ring, fd, 1ULL << 32);\n}\n\nint main(int argc, char *argv[])\n{\n\tstruct io_uring ring;\n\tint dfd, ret;\n\n\tif (argc > 1)\n\t\treturn T_EXIT_SKIP;\n\n\tdfd = open(\"/tmp\", O_RDONLY | O_DIRECTORY);\n\tif (dfd < 0)\n\t\tDIE(\"open /tmp: %s\\n\", strerror(errno));\n\n\tret = io_uring_queue_init(RSIZE, &ring, 0);\n\tif (ret < 0)\n\t\tDIE(\"failed to init io_uring: %s\\n\", strerror(-ret));\n\n\tret = test_open_write(&ring, dfd, \"io_uring_openat_write_test1\");\n\n\tio_uring_queue_exit(&ring);\n\tclose(dfd);\n\tunlink(\"/tmp/io_uring_openat_write_test1\");\n\treturn ret;\n}\n"},
                          "roles": ["analysisTarget",
                                    "tracedFile"]}],
           "results": [{"ruleId": "-Wanalyzer-fd-leak",
                        "taxa": [{"id": "775",
                                  "toolComponent": {"name": "cwe"}}],
                        "properties": {"gcc/analyzer/saved_diagnostic/sm": "file-descriptor",
                                       "gcc/analyzer/saved_diagnostic/ploc": {"enode": 40},
                                       "gcc/analyzer/saved_diagnostic/var": "open (\"/tmp\", 65536)",
                                       "gcc/analyzer/saved_diagnostic/sval": "CONJURED(_13 = open (\"/tmp\", 65536);, _13)",
                                       "gcc/analyzer/saved_diagnostic/state": "fd-valid-read-only",
                                       "gcc/analyzer/saved_diagnostic/idx": 0,
                                       "gcc/analyzer/saved_diagnostic/duplicates": [{"properties": {"gcc/analyzer/saved_diagnostic/sm": "file-descriptor",
                                                                                                    "gcc/analyzer/saved_diagnostic/ploc": {"enode": 40},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "open (\"/tmp\", 65536)",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "CONJURED(_13 = open (\"/tmp\", 65536);, _13)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "fd-valid-read-only",
                                                                                                    "gcc/analyzer/saved_diagnostic/idx": 1,
                                                                                                    "gcc/analyzer/pending_diagnostic/kind": "fd_leak"}}],
                                       "gcc/analyzer/pending_diagnostic/kind": "fd_leak"},
                        "level": "warning",
                        "message": {"text": "leak of file descriptor ‘open(\"/tmp\", 65536)’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 110,
                                                                       "startColumn": 12,
                                                                       "endColumn": 13},
                                                            "contextRegion": {"startLine": 110,
                                                                              "snippet": {"text": "\tif (ret < 0)\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "main"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 18,
                                                                                                                                 "dst_id": 20}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 102,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 102,
                                                                                                                           "snippet": {"text": "\tif (argc > 1)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘argc <= 1’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 18,
                                                                                                                                 "dst_id": 20}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 105,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 51},
                                                                                                         "contextRegion": {"startLine": 105,
                                                                                                                           "snippet": {"text": "\tdfd = open(\"/tmp\", O_RDONLY | O_DIRECTORY);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 105,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 51},
                                                                                                         "contextRegion": {"startLine": 105,
                                                                                                                           "snippet": {"text": "\tdfd = open(\"/tmp\", O_RDONLY | O_DIRECTORY);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "opened here"}},
                                                                       "kinds": ["acquire",
                                                                                 "resource"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 106,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 106,
                                                                                                                           "snippet": {"text": "\tif (dfd < 0)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "assuming ‘open(\"/tmp\", 65536)’ is a valid file descriptor (>= 0)"}},
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 4},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(5)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 21,
                                                                                                                                 "dst_id": 29}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 106,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 106,
                                                                                                                           "snippet": {"text": "\tif (dfd < 0)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "following ‘false’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 5},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(6)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 21,
                                                                                                                                 "dst_id": 29}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 109,
                                                                                                                    "startColumn": 15,
                                                                                                                    "endColumn": 51},
                                                                                                         "contextRegion": {"startLine": 109,
                                                                                                                           "snippet": {"text": "\tret = io_uring_queue_init(RSIZE, &ring, 0);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "lfs-openat-write.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 110,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 110,
                                                                                                                           "snippet": {"text": "\tif (ret < 0)\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "main"}],
                                                                                    "message": {"text": "‘open(\"/tmp\", 65536)’ leaks here; was opened at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7}]}]}]}],
           "logicalLocations": [{"name": "main",
                                 "fullyQualifiedName": "main",
                                 "decoratedName": "main",
                                 "kind": "function",
                                 "index": 0}]}]}
