diff options
author | dec05eba <dec05eba@protonmail.com> | 2024-10-06 22:26:47 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2024-10-06 22:26:47 +0200 |
commit | 28ba2e8f3eeee6bd81e5af431d79a612f85e11bf (patch) | |
tree | 88aac71c60a641a08336c8b0ecef735bf53a16b2 /src/utils.c | |
parent | 29a21ffff0c1447284957ed3b12a73e12bcdc3fb (diff) |
gsr-kms-server 'security': only allow gpu-screen-recorder to get framebuffer
Diffstat (limited to 'src/utils.c')
-rw-r--r-- | src/utils.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/utils.c b/src/utils.c index 42f4c40..6fe5904 100644 --- a/src/utils.c +++ b/src/utils.c @@ -464,23 +464,14 @@ static bool try_card_has_valid_plane(const char *card_path) { return false; } -static void string_copy(char *dst, const char *src, int len) { - int src_len = strlen(src); - int min_len = src_len; - if(len - 1 < min_len) - min_len = len - 1; - memcpy(dst, src, min_len); - dst[min_len] = '\0'; -} - bool gsr_get_valid_card_path(gsr_egl *egl, char *output, bool is_monitor_capture) { if(egl->dri_card_path) { - string_copy(output, egl->dri_card_path, 127); + snprintf(output, 128, "%s", egl->dri_card_path); return is_monitor_capture ? try_card_has_valid_plane(output) : true; } for(int i = 0; i < 10; ++i) { - snprintf(output, 127, DRM_DEV_NAME, DRM_DIR_NAME, i); + snprintf(output, 128, DRM_DEV_NAME, DRM_DIR_NAME, i); if(try_card_has_valid_plane(output)) return true; } @@ -494,7 +485,7 @@ bool gsr_card_path_get_render_path(const char *card_path, char *render_path) { char *render_path_tmp = drmGetRenderDeviceNameFromFd(fd); if(render_path_tmp) { - string_copy(render_path, render_path_tmp, 127); + snprintf(render_path, 128, "%s", render_path_tmp); free(render_path_tmp); close(fd); return true; |