projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix all strncpy() usage: need to set a final \0 character at the end
[lttng-tools.git]
/
liblttsessiondcomm
/
liblttsessiondcomm.c
diff --git
a/liblttsessiondcomm/liblttsessiondcomm.c
b/liblttsessiondcomm/liblttsessiondcomm.c
index cffeb72c0d71f0d9ead2b6a61f4ac78ebf18d875..cecd89d6a5815fc7ee1e472821474afc4785dc39 100644
(file)
--- a/
liblttsessiondcomm/liblttsessiondcomm.c
+++ b/
liblttsessiondcomm/liblttsessiondcomm.c
@@
-28,7
+28,7
@@
#include <unistd.h>
#include <assert.h>
#include <unistd.h>
#include <assert.h>
-#include
"liblttsessiondcomm.h"
+#include
<lttng/lttng-sessiond-comm.h>
/*
* Human readable error message.
/*
* Human readable error message.
@@
-127,6
+127,7
@@
int lttcomm_connect_unix_sock(const char *pathname)
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
+ sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun));
if (ret < 0) {
ret = connect(fd, (struct sockaddr *) &sun, sizeof(sun));
if (ret < 0) {
@@
-191,7
+192,8
@@
int lttcomm_create_unix_sock(const char *pathname)
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_UNIX;
- strncpy(sun.sun_path, pathname, strlen(pathname));
+ strncpy(sun.sun_path, pathname, sizeof(sun.sun_path));
+ sun.sun_path[sizeof(sun.sun_path) - 1] = '\0';
/* Unlink the old file if present */
(void) unlink(pathname);
/* Unlink the old file if present */
(void) unlink(pathname);
This page took
0.025522 seconds
and
5
git commands to generate.