diff mbox series

[V2,2/2] Added missing copyright for strlcpy function

Message ID 20201231102935.85706-3-sbabic@denx.de
State Accepted
Headers show
Series Fix copyright and license for strlcpy | expand

Commit Message

Stefano Babic Dec. 31, 2020, 10:29 a.m. UTC
strlcpy() does not exist in Linux and the function in SWUpdate was taken
from FreeBSD code. Add the missing Copyright of the author.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Reported-by: Bastian Germann <bage@linutronix.de>
---
 core/Makefile  |  3 ++-
 core/strlcpy.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 core/util.c    | 33 ---------------------------------
 3 files changed, 47 insertions(+), 34 deletions(-)
 create mode 100644 core/strlcpy.c

Comments

Bastian Germann Jan. 2, 2021, 12:13 a.m. UTC | #1
In my opinion, the isc.txt should not take the two leading copyright 
lines. Also, the version that strlcpy comes with does not have the "/or" 
clarification and the disclaimer does not say "ISC" but "THE AUTHOR" (2x).
Stefano Babic Jan. 2, 2021, 10:01 a.m. UTC | #2
Hi Bastian,

On 02.01.21 01:13, Bastian Germann wrote:
> In my opinion, the isc.txt should not take the two leading copyright 
> lines. Also, the version that strlcpy comes with does not have the "/or" 
> clarification and the disclaimer does not say "ISC" but "THE AUTHOR" (2x).

License text is taken according to SPDX https://spdx.org/, and one good 
reason is to avoid to have different text in any header.

Maybe this is because it is *not* under ISC. Code is coming from freeBSD:

	https://github.com/freebsd/freebsd-src/blob/master/sys/libkern/strlcpy.c

so it must be licensed under a freeBSD license. The more correct is then 
https://spdx.org/licenses/BSD-2-Clause-FreeBSD.html (even if deprecated, 
I do not see a release text for version 3.10). IMHO license should then 
be set to BSD-2-Clause-FreeBSD instead of ISC.

Best regards,
Stefano
Bastian Germann Jan. 2, 2021, 11:58 a.m. UTC | #3
Am 02.01.21 um 11:01 schrieb Stefano Babic:
> Hi Bastian,
> 
> On 02.01.21 01:13, Bastian Germann wrote:
>> In my opinion, the isc.txt should not take the two leading copyright 
>> lines. Also, the version that strlcpy comes with does not have the 
>> "/or" clarification and the disclaimer does not say "ISC" but "THE 
>> AUTHOR" (2x).
> 
> License text is taken according to SPDX https://spdx.org/, and one good 
> reason is to avoid to have different text in any header.
> 
> Maybe this is because it is *not* under ISC. Code is coming from freeBSD:
> 
>      https://github.com/freebsd/freebsd-src/blob/master/sys/libkern/strlcpy.c
> 
> so it must be licensed under a freeBSD license. The more correct is then 
> https://spdx.org/licenses/BSD-2-Clause-FreeBSD.html (even if deprecated, 
> I do not see a release text for version 3.10). IMHO license should then 
> be set to BSD-2-Clause-FreeBSD instead of ISC.

That is not correct. The origin of strlcpy is OpenBSD and FreeBSD copied 
it from there including the ISC license (because they would otherwise 
violate it). When you have a look at the file that you referenced it is 
clearly the ISC license and not the 2-clause BSD (where are the two 
clauses in strlcpy.c?).

The mentioned variants of the ISC license are colored in 
https://spdx.org/licenses/ISC.html and with SPDX Matching Guidelines 
2.1.3 and 2.1.4 the license matches. However, I do not know if the 
copyrightHolder and copyrightHolderLiability variables have to be filled 
in the SPDX license header with "THE AUTHOR" then or if it is okay as it 
is (original="ISC").

In the other license files you left out the copyright notices at the 
beginning.

> 
> Best regards,
> Stefano
>
Stefano Babic Jan. 2, 2021, 12:40 p.m. UTC | #4
Hi Bastian,

On 02.01.21 12:58, Bastian Germann wrote:
> Am 02.01.21 um 11:01 schrieb Stefano Babic:
>> Hi Bastian,
>>
>> On 02.01.21 01:13, Bastian Germann wrote:
>>> In my opinion, the isc.txt should not take the two leading copyright 
>>> lines. Also, the version that strlcpy comes with does not have the 
>>> "/or" clarification and the disclaimer does not say "ISC" but "THE 
>>> AUTHOR" (2x).
>>
>> License text is taken according to SPDX https://spdx.org/, and one 
>> good reason is to avoid to have different text in any header.
>>
>> Maybe this is because it is *not* under ISC. Code is coming from freeBSD:
>>
>>      https://github.com/freebsd/freebsd-src/blob/master/sys/libkern/strlcpy.c 
>>
>>
>> so it must be licensed under a freeBSD license. The more correct is 
>> then https://spdx.org/licenses/BSD-2-Clause-FreeBSD.html (even if 
>> deprecated, I do not see a release text for version 3.10). IMHO 
>> license should then be set to BSD-2-Clause-FreeBSD instead of ISC.
> 
> That is not correct. The origin of strlcpy is OpenBSD and FreeBSD copied 
> it from there including the ISC license (because they would otherwise 
> violate it). When you have a look at the file that you referenced it is 
> clearly the ISC license and not the 2-clause BSD (where are the two 
> clauses in strlcpy.c?).

Ok - then if openBSD is the origin, openBSD license rules and file 
should be marked as ISC, what the patch is already setting.

> 
> The mentioned variants of the ISC license are colored in 
> https://spdx.org/licenses/ISC.html and with SPDX Matching Guidelines 
> 2.1.3 and 2.1.4 the license matches. However, I do not know if the 
> copyrightHolder and copyrightHolderLiability variables have to be filled 
> in the SPDX license header with "THE AUTHOR" then or if it is okay as it 
> is (original="ISC").

This ISC license text is already integrated in Yocto/OE, openWRT, U-Boot 
(and maybe in other projects). I do not want to create a SWupdate 
variant. So IMHO this is ok.

> 
> In the other license files you left out the copyright notices at the 
> beginning.
> 

Same is done (I checked before) in OE, so SWUpdate is at least aligned 
with other FOSS projects.

Best regards,
Stefano
diff mbox series

Patch

diff --git a/core/Makefile b/core/Makefile
index 11bc183..0ad6f22 100644
--- a/core/Makefile
+++ b/core/Makefile
@@ -25,4 +25,5 @@  obj-y += swupdate.o \
 	 parsing_library.o \
 	 artifacts_versions.o \
 	 swupdate_dict.o \
-	 semver.o
+	 semver.o \
+	 strlcpy.o
diff --git a/core/strlcpy.c b/core/strlcpy.c
new file mode 100644
index 0000000..3c8dca4
--- /dev/null
+++ b/core/strlcpy.c
@@ -0,0 +1,45 @@ 
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * SPDX-License-Identifier:     ISC
+ */
+
+#include <sys/types.h>
+#include "util.h"
+#if defined(__linux__)
+
+/*
+ * strlcpy() does not exist in Linux, and this function is copied from freebsd
+ *
+ */
+
+/*
+ * Copy string src to buffer dst of size dsize.  At most dsize-1
+ * chars will be copied.  Always NUL terminates (unless dsize == 0).
+ * Returns strlen(src); if retval >= dsize, truncation occurred.
+ */
+size_t
+strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize)
+{
+	const char *osrc = src;
+	size_t nleft = dsize;
+
+	/* Copy as many bytes as will fit. */
+	if (nleft != 0) {
+		while (--nleft != 0) {
+			if ((*dst++ = *src++) == '\0')
+				break;
+		}
+	}
+
+	/* Not enough room in dst, add NUL and traverse rest of src. */
+	if (nleft == 0) {
+		if (dsize != 0)
+			*dst = '\0';		/* NUL-terminate dst */
+		while (*src++)
+			;
+	}
+
+	return(src - osrc - 1);	/* count does not include NUL */
+}
+#endif
diff --git a/core/util.c b/core/util.c
index 69d02c5..2025276 100644
--- a/core/util.c
+++ b/core/util.c
@@ -223,39 +223,6 @@  char *substring(const char *src, int first, int len) {
 	return s;
 }
 
-#if defined(__linux__)
-
-/*
- * Copy string src to buffer dst of size dsize.  At most dsize-1
- * chars will be copied.  Always NUL terminates (unless dsize == 0).
- * Returns strlen(src); if retval >= dsize, truncation occurred.
- */
-size_t
-strlcpy(char * __restrict dst, const char * __restrict src, size_t dsize)
-{
-	const char *osrc = src;
-	size_t nleft = dsize;
-
-	/* Copy as many bytes as will fit. */
-	if (nleft != 0) {
-		while (--nleft != 0) {
-			if ((*dst++ = *src++) == '\0')
-				break;
-		}
-	}
-
-	/* Not enough room in dst, add NUL and traverse rest of src. */
-	if (nleft == 0) {
-		if (dsize != 0)
-			*dst = '\0';		/* NUL-terminate dst */
-		while (*src++)
-			;
-	}
-
-	return(src - osrc - 1);	/* count does not include NUL */
-}
-#endif
-
 int openfileoutput(const char *filename)
 {
 	int fdout;