Exploit database

GH-f838dcf62fc9fa430d033ea61489fdd5

wonjj6768/lenovo-tb365fc-ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files7

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

su/src/client.h

Text · 2,087 bytes
#ifndef ROOTD_CLIENT_H
#define ROOTD_CLIENT_H

/* Client helpers shared by su and rootmgr. */

#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <unistd.h>

#include "protocol.h"
#include "uid.h"

static int connect_rootd(void) {
    int fd = socket(AF_UNIX, SOCK_STREAM, 0);
    if (fd < 0) return -1;
    struct sockaddr_un sa;
    memset(&sa, 0, sizeof(sa));
    sa.sun_family = AF_UNIX;
    strncpy(sa.sun_path, ROOTD_SOCK, sizeof(sa.sun_path) - 1);
    if (connect(fd, (struct sockaddr *)&sa, sizeof(sa)) == 0) return fd;
    int e = errno;   /* close() may clobber errno; preserve the connect() cause */
    close(fd);
    errno = e;
    return -1;
}

/* Strip a trailing "[ghostlock-exit:N]", its preceding newline and optional
 * final newline. Return the output length and set status/seen on a match;
 * otherwise return len with seen = 0. Embedded sentinels remain output. */
static size_t strip_exit_sentinel(const unsigned char *buf, size_t len,
                                  int *status, int *seen) {
    const size_t slen = sizeof(ROOTD_EXIT_SENTINEL) - 1;
    *seen = 0;
    for (size_t i = len; i-- > 0;) {
        if (buf[i] != '[' || len - i < slen) continue;
        if (memcmp(buf + i, ROOTD_EXIT_SENTINEL, slen) != 0) continue;
        size_t j = i + slen;
        long v = 0;
        int nd = 0, bad = 0;
        while (j < len && buf[j] >= '0' && buf[j] <= '9') {
            if (nd >= 9) { bad = 1; break; }
            v = v * 10 + (long)(buf[j] - '0');
            nd++; j++;
        }
        if (bad || nd == 0) continue;
        if (j >= len || buf[j] != ']') continue;
        /* Must be trailing: only an optional single '\n' may follow ']'. */
        size_t after = j + 1;
        if (after < len && !(buf[after] == '\n' && after + 1 == len)) continue;
        size_t out = i;
        if (out > 0 && buf[out - 1] == '\n') out--;
        *status = (int)v;
        *seen = 1;
        return out;
    }
    return len;
}

#endif