From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Mon, 31 Jul 2017 22:30:40 +0300 From: "Dmitry V. Levin" To: ALT Devel discussion list Message-ID: <20170731193039.GA9100@altlinux.org> Mail-Followup-To: ALT Devel discussion list References: <043c96a8-c577-6952-09be-2ed9f7e44845@gmail.com> <4539b76c-8dcc-5fbb-e4ca-4244cf4cc5f8@gmail.com> <20170731095807.GC29253@imap.altlinux.org> <20170731101547.GA5776@lks.home> <20170731105224.GA2854@altlinux.org> <382cf736-040a-ea18-4404-8835b2e26ec1@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="98e8jtXdkpgskNou" Content-Disposition: inline In-Reply-To: <382cf736-040a-ea18-4404-8835b2e26ec1@gmail.com> Subject: Re: [devel] =?koi8-r?b?/tTPINzUzz8g8MXSxc/Q0sXExczFzsnFIMbVzsvDyco/?= X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 Jul 2017 19:30:40 -0000 Archived-At: List-Archive: List-Post: --98e8jtXdkpgskNou Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV" Content-Disposition: inline --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jul 31, 2017 at 09:56:02PM +0300, =E4=CD=C9=D4=D2=C9=CA =E8=C1=CE= =D6=C9=CE wrote: > 31.07.2017 13:52, Dmitry V. Levin =D0=C9=DB=C5=D4: > > Hi, > >=20 > > =F4=C5=CB=D5=DD=C5=C5 =D3=CF=D3=D4=CF=D1=CE=C9=C5 =D0=CF =C4=CF=C2=C1= =D7=CC=C5=CE=C9=C0 strlcpy =C9 strlcat =D7 glibc: > > https://sourceware.org/ml/libc-alpha/2017-06/msg00703.html > > =EE=C1 =C4=C1=CE=CE=D9=CA =CD=CF=CD=C5=CE=D4 =CF=D3=D4=C1=CC=D3=D1 =D4= =CF=CC=D8=CB=CF =CF=C4=C9=CE =DE=C5=CC=CF=D7=C5=CB, =D0=D2=C5=D0=D1=D4=D3= =D4=D7=D5=C0=DD=C9=CA =D0=D2=C9=CE=D1=D4=C9=C0 > > =DC=D4=CF=C7=CF =D0=C1=D4=DE=C1. =EE=D5 =DE=D4=CF =D6=C5, =D0=CF=C4=CF= =D6=C4=A3=CD =C5=DD=A3 =CE=C5=CD=CE=CF=C7=CF. > > >=20 > =F7=CF=D4 =DE=D4=CF =CD=CE=C5 =CF=D4=D7=C5=D4=C9=CC=C9: >=20 > > Thanks for your comment! > > If we modify the prototype declaration will it then not conflict with o= ther distributions? > > __THROW is a preprocesor symbol which not all compilers may have? > > Similar for __nonnull. > > The declarations we have now originate from OpenBSD/FreeBSD. > > ALT Linux wants to improve on them and so introduces differences? > > Does ALT Linux have a preprocessor symbol by which we can identify it? > > Is there a way we can avoid the ALT Linux declaration from string.h? > > Could you perhaps attach the output of g++ -E /usr/include/string.h ? > > What would be harmless is if you add a extern "C" linkage specification. > > Would that suffice? Probably not. > > What does the ALT Linux team say? > > Sorry for all the questions. >=20 > =F0=D2=CF=CB=CF=CD=CD=C5=CE=D4=C9=D2=D5=CA=D4=C5, =D0=CF=D6=C1=CC=D5=CA= =D3=D4=C1, =D1 =D4=C1=CB =C7=CC=D5=C2=CF=CB=CF =CE=C5 =C9=CE=D4=C5=D2=C5=D3= =CF=D7=C1=CC=D3=D1. =E1=D0=D3=D4=D2=C9=CD =CE=C5 =D7 =D4=C5=CD=C5, =C9, =D3=D5=C4=D1 =D0=CF =CB= =CF=C4=D5, =CE=C5 =D3=CB=CF=D2=CF =C2=D5=C4=C5=D4 =D7 =D4=C5=CD=C5. =F0=CF=D0=D2=CF=C2=D5=CA=D4=C5 =D3 =D0=D2=C9=CC=CF=D6=C5=CE=CE=D9=CD =D0=C1= =D4=DE=C5=CD, =D1 =C5=C7=CF =CE=C5 =D0=D2=CF=C2=CF=D7=C1=CC =CB=CF=CD=D0=C9= =CC=C9=D2=CF=D7=C1=D4=D8, =CE=CF, =D0=CF=CC=C1=C7=C1=C0, =DE=D4=CF =CF=CE =D0=CF=CD=CF=D6=C5=D4. =EE= =C5 =DA=C1=C2=D5=C4=D8=D4=C5 =D0=C5=D2=C5=C7=C5=CE=C5=D2=C9=D4=D8 configure. > =F3=D3=D9=CC=CB=D5 =D7=D9=DB=C5 =D0=D2=CF=DE=C9=D4=C1=CC, =CE=CF =D4=CF= =D6=C5 =CE=C9=DE=C5=C7=CF =CE=C5 =D0=CF=CE=D1=CC. :-( =F6=C1=CC=D8. --=20 ldv --HcAYCG3uE/tztfnV Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="0001-Do-not-override-strlcpy-and-strlcat-provided-by-the-.patch" Content-Transfer-Encoding: quoted-printable =46rom 2939af61a1e92f7f03950a57f74abaa5bcd0ac07 Mon Sep 17 00:00:00 2001 =46rom: "Dmitry V. Levin" Date: Mon, 31 Jul 2017 19:17:17 +0000 Subject: [PATCH] Do not override strlcpy and strlcat provided by the OS --- configure.ac | 2 +- src/base.h | 5 +++++ src/misc.cc | 7 +++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index fe9176e..b004fd2 100644 --- a/configure.ac +++ b/configure.ac @@ -119,7 +119,7 @@ if test x$cross_compling !=3D xyes ; then :; AC_FUNC_MA= LLOC fi AC_FUNC_MMAP if test x$cross_compling !=3D xyes ; then :; AC_FUNC_REALLOC fi AC_FUNC_STRNLEN -AC_CHECK_FUNCS([dup2 getcwd gethostbyname gethostname gettimeofday mblen m= emchr memmove memset mkdir nl_langinfo putenv select setlocale socket strca= secmp strchr strcspn strdup strerror strncasecmp strrchr strspn strstr strt= ol sysinfo uname abort wordexp]) +AC_CHECK_FUNCS([dup2 getcwd gethostbyname gethostname gettimeofday mblen m= emchr memmove memset mkdir nl_langinfo putenv select setlocale socket strca= secmp strchr strcspn strdup strerror strlcpy strlcat strncasecmp strrchr st= rspn strstr strtol sysinfo uname abort wordexp]) AC_CHECK_FUNCS([gettimeofday putenv select socket strtol strtoul basename]) AC_CHECK_FUNCS([sysctlbyname asprintf]) AC_CHECK_FUNC([getloadavg],[AC_DEFINE([HAVE_GETLOADAVG2], 1, [getloadavg()= is available])]) diff --git a/src/base.h b/src/base.h index 0df34cc..b76ec69 100644 --- a/src/base.h +++ b/src/base.h @@ -1,6 +1,7 @@ #ifndef __BASE_H #define __BASE_H =20 +#include "config.h" #include =20 #ifndef __GNUC__ @@ -48,10 +49,14 @@ inline T abs(T v) { =20 /*** String Functions ****************************************************= *****/ =20 +#ifndef HAVE_STRLCPY /* Prefer this as a safer alternative over strcpy. Return strlen(from). */ size_t strlcpy(char *dest, const char *from, size_t dest_size); +#endif +#ifndef HAVE_STRLCAT /* Prefer this over strcat. Return strlen(dest) + strlen(from). */ size_t strlcat(char *dest, const char *from, size_t dest_size); +#endif =20 char *newstr(char const *str); char *newstr(char const *str, int len); diff --git a/src/misc.cc b/src/misc.cc index b0ac1c9..3a88276 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -447,6 +447,8 @@ void operator delete[](void *p) { =20 #endif =20 +#ifndef HAVE_STRLCPY + /* Prefer this as a safer alternative over strcpy. Return strlen(from). */ size_t strlcpy(char *dest, const char *from, size_t dest_size) { @@ -461,6 +463,9 @@ size_t strlcpy(char *dest, const char *from, size_t des= t_size) while (*in) ++in; return in - from; } +#endif + +#ifndef HAVE_STRLCAT =20 /* Prefer this over strcat. Return strlen(dest) + strlen(from). */ size_t strlcat(char *dest, const char *from, size_t dest_size) @@ -471,6 +476,8 @@ size_t strlcat(char *dest, const char *from, size_t des= t_size) return to - dest + strlcpy(to, from, dest_size - (to - dest)); } =20 +#endif + char *newstr(char const *str) { return (str !=3D NULL ? newstr(str, strlen(str)) : NULL); } --=20 ldv --HcAYCG3uE/tztfnV-- --98e8jtXdkpgskNou Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIcBAEBCAAGBQJZf4VfAAoJEAVFT+BVnCUI8A0P/iJeCik5e2bGnf0keaVQoyHq AKdVtRu0Yc7HJl7739M9Ptg/X20gDsqzpLfrzWH7ezqiSeZKpZfVW37N76UAiRm2 9C8Shk+J4HLCaWIqRsI2nefdIByP9XSzlicPJy6/ZY3wr28D0LFzUY2vDoR4Rbdn RnxwLo7HpOe4axwyZWJ+X9FZqI5LCPF0Y1gTVa0q6oIR5dH0VqMFwjSnOvZJBYWB c8Gricf81DKMOpvvdv3VPSqI0gtO7rrLTVEzgJZ0TSZmFRqIWTHWKFETPPVf8ZDI s9k8tdkPQqISmyNDEfx7TxLVkQF+9CHklp0gtOEkZDkN0+T3D9T/6rluPdbUKHdg gpCQ32oV30QaOk9ja7huXOna5mn2UqaR6KBa/O19tDkaM4UbQdrledezmSoXGt63 8BwPYA4x/ivSLz0sXnz7NRtGH2qvEkOL4J3ZdfPFpWwJw20wbfD1muCku5P4q0/U IH27Vc5Ob65aeA4exQkr/F3HGBHdttfzrefgPzUsSN7Vli0i5HGRi8/h5U7pE8s2 UJJyOk2VUJwRAeUHbohVPXvyWQ3fwclJtKhJcGGCY/0zx4RoBrT5vprfmygDX7zN 95no+6ojtWq9gy/mCDbqOfPMlfNO4gf9ap81xdDDC2XA6koOqNYCQM56XcU1/Jlb z+6BX3m75yBYPDAPPK2t =1enU -----END PGP SIGNATURE----- --98e8jtXdkpgskNou--