aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-06-04 23:03:39 +0200
committerSimon Ser <contact@emersion.fr>2022-06-04 23:03:39 +0200
commitc2952411d388c09fa4e90aca3c27e5d2e74bd413 (patch)
tree724b252449918403175571a07be84b9a0eba12a4
parent366e8e3b9163d29bfcb75c97d482aa730d0dfc11 (diff)
examples/screencopy-dmabuf: stop using strncpy
strncpy doesn't guarantee that the result is zero-terminated.
-rw-r--r--examples/screencopy-dmabuf.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/examples/screencopy-dmabuf.c b/examples/screencopy-dmabuf.c
index e7657e1a..f16c29da 100644
--- a/examples/screencopy-dmabuf.c
+++ b/examples/screencopy-dmabuf.c
@@ -76,7 +76,7 @@ static const struct format formats[] = {
{DRM_FORMAT_ABGR8888, false},
};
-static bool find_render_node(char *node, size_t maxlen) {
+static bool find_render_node(char *node, size_t node_size) {
bool r = false;
drmDevice *devices[64];
@@ -87,8 +87,7 @@ static bool find_render_node(char *node, size_t maxlen) {
continue;
}
- strncpy(node, dev->nodes[DRM_NODE_RENDER], maxlen - 1);
- node[maxlen - 1] = '\0';
+ snprintf(node, node_size, "%s", dev->nodes[DRM_NODE_RENDER]);
r = true;
break;
}