[lxc-devel] [lxc/master] btrfs: s/strncat()/strlcat()/g
brauner on Github
lxc-bot at linuxcontainers.org
Wed Jun 20 15:54:08 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180620/219eea47/attachment.bin>
-------------- next part --------------
From 3afafe55cc897f86b850795be630add1e277b164 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Wed, 20 Jun 2018 17:53:19 +0200
Subject: [PATCH] btrfs: s/strncat()/strlcat()/g
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
src/lxc/Makefile.am | 8 ++++++++
src/lxc/storage/btrfs.c | 10 +++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/lxc/Makefile.am b/src/lxc/Makefile.am
index 99b5291d1..313475824 100644
--- a/src/lxc/Makefile.am
+++ b/src/lxc/Makefile.am
@@ -159,6 +159,10 @@ if !HAVE_STRLCPY
liblxc_la_SOURCES += ../include/strlcpy.c ../include/strlcpy.h
endif
+if !HAVE_STRLCAT
+liblxc_la_SOURCES += ../include/strlcat.c ../include/strlcat.h
+endif
+
if !HAVE_GETGRGID_R
liblxc_la_SOURCES += ../include/getgrgid_r.c ../include/getgrgid_r.h
endif
@@ -316,6 +320,10 @@ if !HAVE_STRLCPY
init_lxc_static_SOURCES += ../include/strlcpy.c ../include/strlcpy.h
endif
+if !HAVE_STRLCAT
+init_lxc_static_SOURCES += ../include/strlcat.c ../include/strlcat.h
+endif
+
if !HAVE_GETGRGID_R
liblxc_la_SOURCES += ../include/getgrgid_r.c ../include/getgrgid_r.h
endif
diff --git a/src/lxc/storage/btrfs.c b/src/lxc/storage/btrfs.c
index 3458b1f65..c83ddf4e8 100644
--- a/src/lxc/storage/btrfs.c
+++ b/src/lxc/storage/btrfs.c
@@ -46,6 +46,10 @@
#include "include/strlcpy.h"
#endif
+#ifndef HAVE_STRLCAT
+#include "include/strlcat.h"
+#endif
+
lxc_log_define(btrfs, lxc);
/*
@@ -89,8 +93,8 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
if (!retpath)
return NULL;
(void)strlcpy(retpath, args.name, len);
- strncat(retpath, "/", 1);
- strncat(retpath, name, name_len);
+ (void)strlcat(retpath, "/", 1);
+ (void)strlcat(retpath, name, name_len);
} else {
/* we're at the root of ref_tree */
len = name_len + 1;
@@ -98,7 +102,7 @@ char *get_btrfs_subvol_path(int fd, u64 dir_id, u64 objid, char *name,
if (!retpath)
return NULL;
*retpath = '\0';
- strncat(retpath, name, name_len);
+ (void)strlcat(retpath, name, name_len);
}
return retpath;
}
More information about the lxc-devel
mailing list