Retrieve opened socket by its fd index. In case of a error, the appropriate error number is returned.
(os: QlOsPosix, fd: int)
| 162 | |
| 163 | |
| 164 | def get_opened_socket(os: QlOsPosix, fd: int) -> Union[ql_socket, int]: |
| 165 | """Retrieve opened socket by its fd index. In case of a error, the |
| 166 | appropriate error number is returned. |
| 167 | """ |
| 168 | |
| 169 | # fd out of range? |
| 170 | if fd not in range(NR_OPEN): |
| 171 | return -EBADF |
| 172 | |
| 173 | sock = os.fd[fd] |
| 174 | |
| 175 | # not an opened file? |
| 176 | if sock is None: |
| 177 | return -EBADF |
| 178 | |
| 179 | # not a socket? |
| 180 | if not isinstance(sock, ql_socket): |
| 181 | return -ENOTSOCK |
| 182 | |
| 183 | return sock |
| 184 | |
| 185 | |
| 186 | def ql_syscall_socket(ql: Qiling, domain: int, socktype: int, protocol: int): |
no outgoing calls
no test coverage detected