aboutsummaryrefslogtreecommitdiffstats
path: root/src/e1_input_vty.c
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-08-28 14:03:41 +0200
committerStefan Sperling <ssperling@sysmocom.de>2018-09-04 11:51:47 +0200
commitb24efa551dc91e177c5cb8da674e9f8432d52dc9 (patch)
treea54c51c12de1b69f74e7580aa72ea1b31ba37b6c /src/e1_input_vty.c
parent9540f59b1daeac36d71b20ac9cefe15019d6277c (diff)
Properly deal with sockaddr_un socket path length limitations.
When parsing the configuration, reject a socket path which exceeds the maximum size supported by the operating system. In unixsocket_line_update() stop copying the line's socket path to a local buffer. The path will be copied again in osmo_sock_unix_init(). Both changes are portable; we don't assume any particular socket path length since the size differs between implementations of Unix, and we rely only on information from the generic sys/un.h header. Change-Id: I36344805a825f5d0e0c9d218d438d8fd985ed9ca Related: OS#2673
Diffstat (limited to 'src/e1_input_vty.c')
-rw-r--r--src/e1_input_vty.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/e1_input_vty.c b/src/e1_input_vty.c
index 0e4575f..653c573 100644
--- a/src/e1_input_vty.c
+++ b/src/e1_input_vty.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <sys/un.h>
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/talloc.h>
@@ -98,6 +99,14 @@ DEFUN(cfg_e1line_socket, cfg_e1_line_socket_cmd,
{
struct e1inp_line *line;
int e1_nr = atoi(argv[0]);
+ struct sockaddr_un sun;
+
+ /* Don't exceed the maximum unix socket path length. See the unix(7) man page.*/
+ if (strlen(argv[1]) > sizeof(sun.sun_path)) {
+ vty_out(vty, "%% Socket path length exceeds %zd bytes: '%s'%s",
+ sizeof(sun.sun_path), argv[1], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
line = e1inp_line_find(e1_nr);
if (!line) {