aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libbsc
diff options
context:
space:
mode:
authorNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-01-13 03:12:08 +0100
committerHarald Welte <laforge@gnumonks.org>2017-01-23 11:59:01 +0000
commit93bafb611a58293e0353320a14db298133c9d99a (patch)
tree4ba6d276b7f5e2fda43f21b765d7cca8c6b00d5e /openbsc/src/libbsc
parent59504dc80fe8c0d9a18994d82586a550c7efa341 (diff)
cosmetic: use osmo_strlcpy() everywhere
Shorten some code and make obvious to the reader that the string copy is done in a safe way. Change-Id: I900726cf06d34128db22a3d3d911ee0d1423b1bd
Diffstat (limited to 'openbsc/src/libbsc')
-rw-r--r--openbsc/src/libbsc/abis_nm.c7
-rw-r--r--openbsc/src/libbsc/bsc_rf_ctrl.c3
2 files changed, 4 insertions, 6 deletions
diff --git a/openbsc/src/libbsc/abis_nm.c b/openbsc/src/libbsc/abis_nm.c
index 0c723e8..2698225 100644
--- a/openbsc/src/libbsc/abis_nm.c
+++ b/openbsc/src/libbsc/abis_nm.c
@@ -40,6 +40,7 @@
#include <osmocom/gsm/tlv.h>
#include <osmocom/gsm/abis_nm.h>
#include <osmocom/core/talloc.h>
+#include <osmocom/core/utils.h>
#include <openbsc/abis_nm.h>
#include <openbsc/misdn.h>
#include <openbsc/signal.h>
@@ -2235,8 +2236,7 @@ static int bs11_read_swl_file(struct abis_nm_bs11_sw *bs11_sw)
}
/* construct new filename */
- strncpy(dir, bs11_sw->swl_fname, sizeof(dir));
- dir[sizeof(dir)-1] = '\0';
+ osmo_strlcpy(dir, bs11_sw->swl_fname, sizeof(dir));
strncat(fle->fname, dirname(dir), sizeof(fle->fname) - 1);
strcat(fle->fname, "/");
strncat(fle->fname, file_id, sizeof(fle->fname) - 1 -strlen(fle->fname));
@@ -2307,8 +2307,7 @@ int abis_nm_bs11_load_swl(struct gsm_bts *bts, const char *fname,
bs11_sw->user_cb = cbfn;
bs11_sw->forced = forced;
- strncpy(bs11_sw->swl_fname, fname, sizeof(bs11_sw->swl_fname));
- bs11_sw->swl_fname[sizeof(bs11_sw->swl_fname)-1] = '\0';
+ osmo_strlcpy(bs11_sw->swl_fname, fname, sizeof(bs11_sw->swl_fname));
rc = bs11_read_swl_file(bs11_sw);
if (rc < 0)
return rc;
diff --git a/openbsc/src/libbsc/bsc_rf_ctrl.c b/openbsc/src/libbsc/bsc_rf_ctrl.c
index 0538482..59fac35 100644
--- a/openbsc/src/libbsc/bsc_rf_ctrl.c
+++ b/openbsc/src/libbsc/bsc_rf_ctrl.c
@@ -451,8 +451,7 @@ static int rf_create_socket(struct osmo_bsc_rf *rf, const char *path)
}
local.sun_family = AF_UNIX;
- strncpy(local.sun_path, path, sizeof(local.sun_path));
- local.sun_path[sizeof(local.sun_path) - 1] = '\0';
+ osmo_strlcpy(local.sun_path, path, sizeof(local.sun_path));
unlink(local.sun_path);
/* we use the same magic that X11 uses in Xtranssock.c for