{"$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",
                                          "helpers.c",
                                          "-quiet",
                                          "-dumpbase",
                                          "helpers.c",
                                          "-dumpbase-ext",
                                          ".c",
                                          "-m64",
                                          "-mtune=generic",
                                          "-march=x86-64",
                                          "-mtls-dialect=gnu2",
                                          "-O2",
                                          "-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/6114-yyCi.sarif",
                                          "-o",
                                          "/tmp/ccUxDiUH.s"],
                            "workingDirectory": {"uri": "/builddir/build/BUILD/liburing-2.13-build/liburing-2.13/examples"},
                            "startTimeUtc": "2026-08-03T18:02:14Z",
                            "executionSuccessful": true,
                            "toolExecutionNotifications": [],
                            "endTimeUtc": "2026-08-03T18:02:15Z"}],
           "originalUriBaseIds": {"PWD": {"uri": "file:///builddir/build/BUILD/liburing-2.13-build/liburing-2.13/examples/"}},
           "artifacts": [{"location": {"uri": "helpers.c",
                                       "uriBaseId": "PWD"},
                          "sourceLanguage": "c",
                          "contents": {"text": "/* SPDX-License-Identifier: MIT */\n#include <fcntl.h>\n#include <stdint.h>\n#include <netinet/in.h>\n#include <arpa/inet.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <string.h>\n#include <sys/socket.h>\n#include <sys/time.h>\n#include <unistd.h>\n#include <stdarg.h>\n\n#include \"helpers.h\"\n\n#ifndef CONFIG_HAVE_MEMFD_CREATE\n#include <sys/syscall.h>\nint memfd_create(const char *name, unsigned int flags)\n{\n\treturn (int)syscall(SYS_memfd_create, name, flags);\n}\n#endif\n\nint setup_listening_socket(int port, int ipv6)\n{\n\tstruct sockaddr_in srv_addr = { };\n\tstruct sockaddr_in6 srv_addr6 = { };\n\tint fd, enable, ret, domain;\n\n\tif (ipv6)\n\t\tdomain = AF_INET6;\n\telse\n\t\tdomain = AF_INET;\n\n\tfd = socket(domain, SOCK_STREAM, 0);\n\tif (fd == -1) {\n\t\tperror(\"socket()\");\n\t\treturn -1;\n\t}\n\n\tenable = 1;\n\tret = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int));\n\tif (ret < 0) {\n\t\tperror(\"setsockopt(SO_REUSEADDR)\");\n\t\treturn -1;\n\t}\n\n\tif (ipv6) {\n\t\tsrv_addr6.sin6_family = AF_INET6;\n\t\tsrv_addr6.sin6_port = htons(port);\n\t\tsrv_addr6.sin6_addr = in6addr_any;\n\t\tret = bind(fd, (const struct sockaddr *)&srv_addr6, sizeof(srv_addr6));\n\t} else {\n\t\tsrv_addr.sin_family = AF_INET;\n\t\tsrv_addr.sin_port = htons(port);\n\t\tsrv_addr.sin_addr.s_addr = htonl(INADDR_ANY);\n\t\tret = bind(fd, (const struct sockaddr *)&srv_addr, sizeof(srv_addr));\n\t}\n\n\tif (ret < 0) {\n\t\tperror(\"bind()\");\n\t\treturn -1;\n\t}\n\n\tif (listen(fd, 1024) < 0) {\n\t\tperror(\"listen()\");\n\t\treturn -1;\n\t}\n\n\treturn fd;\n}\n\nvoid *t_aligned_alloc(size_t alignment, size_t size)\n{\n\tvoid *ret;\n\n\tif (posix_memalign(&ret, alignment, size))\n\t\treturn NULL;\n\n\treturn ret;\n}\n\nvoid t_error(int status, int errnum, const char *format, ...)\n{\n\tva_list args;\n\tva_start(args, format);\n\n\tvfprintf(stderr, format, args);\n\tif (errnum)\n\t\tfprintf(stderr, \": %s\", strerror(errnum));\n\n\tfprintf(stderr, \"\\n\");\n\tva_end(args);\n\texit(status);\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": 98},
                                       "gcc/analyzer/saved_diagnostic/var": "fd_14",
                                       "gcc/analyzer/saved_diagnostic/sval": "CONJURED(fd_14 = socket (domain_5, 1, 0);, fd_14)",
                                       "gcc/analyzer/saved_diagnostic/state": "fd-bound-stream-socket",
                                       "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": 98},
                                                                                                    "gcc/analyzer/saved_diagnostic/var": "fd_14",
                                                                                                    "gcc/analyzer/saved_diagnostic/sval": "CONJURED(fd_14 = socket (domain_5, 1, 0);, fd_14)",
                                                                                                    "gcc/analyzer/saved_diagnostic/state": "fd-bound-stream-socket",
                                                                                                    "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 ‘fd’"},
                        "locations": [{"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                 "uriBaseId": "PWD"},
                                                            "region": {"startLine": 71,
                                                                       "startColumn": 1,
                                                                       "endColumn": 2},
                                                            "contextRegion": {"startLine": 71,
                                                                              "snippet": {"text": "}\n"}}},
                                       "logicalLocations": [{"index": 0,
                                                             "fullyQualifiedName": "setup_listening_socket"}]}],
                        "codeFlows": [{"threadFlows": [{"id": "main",
                                                        "locations": [{"properties": {"gcc/analyzer/checker_event/emission_id": "(1)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 35,
                                                                                                                    "startColumn": 14,
                                                                                                                    "endColumn": 44},
                                                                                                         "contextRegion": {"startLine": 35,
                                                                                                                           "snippet": {"text": "\tfd = socket(domain, SOCK_STREAM, 0);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "stream socket created here"}},
                                                                       "kinds": ["acquire",
                                                                                 "resource"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 1},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(2)",
                                                                                      "gcc/analyzer/checker_event/kind": "custom"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 35,
                                                                                                                    "startColumn": 14,
                                                                                                                    "endColumn": 44},
                                                                                                         "contextRegion": {"startLine": 35,
                                                                                                                           "snippet": {"text": "\tfd = socket(domain, SOCK_STREAM, 0);\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "when ‘socket’ succeeds"}},
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 2},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(3)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 36,
                                                                                                                                 "dst_id": 39}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 36,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 36,
                                                                                                                           "snippet": {"text": "\tif (fd == -1) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘fd != -1’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 3},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(4)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 36,
                                                                                                                                 "dst_id": 39}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 41,
                                                                                                                    "startColumn": 9,
                                                                                                                    "endColumn": 19},
                                                                                                         "contextRegion": {"startLine": 41,
                                                                                                                           "snippet": {"text": "\tenable = 1;\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "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": 41,
                                                                                                                                 "dst_id": 44}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 43,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 43,
                                                                                                                           "snippet": {"text": "\tif (ret < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘ret >= 0’)..."}},
                                                                       "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": 41,
                                                                                                                                 "dst_id": 44}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 48,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 48,
                                                                                                                           "snippet": {"text": "\tif (ipv6) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 6},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(7)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 63,
                                                                                                                                 "dst_id": 66}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 60,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 60,
                                                                                                                           "snippet": {"text": "\tif (ret < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "following ‘false’ branch (when ‘ret >= 0’)..."}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 7},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(8)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 63,
                                                                                                                                 "dst_id": 66}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 65,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 29},
                                                                                                         "contextRegion": {"startLine": 65,
                                                                                                                           "snippet": {"text": "\tif (listen(fd, 1024) < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "false"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 8},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(9)",
                                                                                      "gcc/analyzer/checker_event/kind": "state_change"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 65,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 29},
                                                                                                         "contextRegion": {"startLine": 65,
                                                                                                                           "snippet": {"text": "\tif (listen(fd, 1024) < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "stream socket bound here"}},
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 9},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(10)",
                                                                                      "gcc/analyzer/checker_event/kind": "custom"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 65,
                                                                                                                    "startColumn": 13,
                                                                                                                    "endColumn": 29},
                                                                                                         "contextRegion": {"startLine": 65,
                                                                                                                           "snippet": {"text": "\tif (listen(fd, 1024) < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "when ‘listen’ fails"}},
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 10},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(11)",
                                                                                      "gcc/analyzer/checker_event/kind": "start_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 67,
                                                                                                                                 "dst_id": 69}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 65,
                                                                                                                    "startColumn": 12,
                                                                                                                    "endColumn": 13},
                                                                                                         "contextRegion": {"startLine": 65,
                                                                                                                           "snippet": {"text": "\tif (listen(fd, 1024) < 0) {\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "following ‘true’ branch..."}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 11},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(12)",
                                                                                      "gcc/analyzer/checker_event/kind": "end_cfg_edge",
                                                                                      "gcc/analyzer/superedge_event/superedge": {"src_id": 67,
                                                                                                                                 "dst_id": 69}},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 66,
                                                                                                                    "startColumn": 17,
                                                                                                                    "endColumn": 35},
                                                                                                         "contextRegion": {"startLine": 66,
                                                                                                                           "snippet": {"text": "\t\tperror(\"listen()\");\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "...to here"}},
                                                                       "kinds": ["branch",
                                                                                 "true"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 12},
                                                                      {"properties": {"gcc/analyzer/checker_event/emission_id": "(13)",
                                                                                      "gcc/analyzer/checker_event/kind": "warning"},
                                                                       "location": {"physicalLocation": {"artifactLocation": {"uri": "helpers.c",
                                                                                                                              "uriBaseId": "PWD"},
                                                                                                         "region": {"startLine": 71,
                                                                                                                    "startColumn": 1,
                                                                                                                    "endColumn": 2},
                                                                                                         "contextRegion": {"startLine": 71,
                                                                                                                           "snippet": {"text": "}\n"}}},
                                                                                    "logicalLocations": [{"index": 0,
                                                                                                          "fullyQualifiedName": "setup_listening_socket"}],
                                                                                    "message": {"text": "‘fd’ leaks here"}},
                                                                       "kinds": ["danger"],
                                                                       "nestingLevel": 1,
                                                                       "executionOrder": 13}]}]}]}],
           "logicalLocations": [{"name": "setup_listening_socket",
                                 "fullyQualifiedName": "setup_listening_socket",
                                 "decoratedName": "setup_listening_socket",
                                 "kind": "function",
                                 "index": 0}]}]}
