Re: Portability: common-src/ammessage.c
[email protected] (Eric Schnoebelen)
| Newsgroups | gmane.comp.archivers.amanda.devel |
|---|---|
| Message-ID | <[email protected]> |
Jean-Louis Martineau writes: - We don't care if they are defined by gnulib or not, what is - important is the array size, the check should be like: - - #if defined(EBADMSG) && EBADMSG<500 - - A constant should be use instead of harcoding 500, we could - increase it to 2500 - - #define MAX_ERRCODE 500 - char *errcode[MAX_ERRCODE]; - - #if defined(EBADMSG) && EBADMSG<MAX_ERRCODE - - All use of errode[] must also be checked for the value <MAX_ERRCODE All of the above are reasonable. I was attemping a minimally invasive patch for packaging as part of pkgsrc (the cross platform packaging system from NetBSD.) - On 02/01/17 02:41 PM, Eric Schnoebelen wrote: - > common-src/ammessage.c attempts to build an strerror() type - > interface (kinda), allocating an array of 500 elements, which - > are filled in with text versions of the errno values. - > - > The issue? gnulib's version of errno.h creates additional - > values in the 2000 range if the E* values it wants to use aren't - > already defined. And then ammessage.c tries to use the 2000+ - > valued errno values in an array of size 500.. Nice coredump at - > runtime! - > - > Fix: Verify that the errno values weren't defined by gnulib - > before attempting to use them to populate the array. - > - > patch both inline and as an attachment.. - > - > - > $NetBSD$ - > - > Make sure the E* macros aren't GNULIB macros, as those are defined in - > the 2000+ space. - > - > --- common-src/ammessage.c.orig=092016-11-23 16:11:16.000000000 +0000 - > +++ common-src/ammessage.c - > @@ -76,7 +76,7 @@ init_errcode(void) - > #ifdef EBADFD - > errcode[EBADFD] =3D "EBADFD"; - > #endif - > -#ifdef EBADMSG - > +#if defined(EBADMSG) && !defined(GNULIB_defined_EBADMSG) - > errcode[EBADMSG] =3D "EBADMSG"; - > #endif - > #ifdef EBADR - > @@ -91,7 +91,7 @@ init_errcode(void) - > #ifdef EBUSY - > errcode[EBUSY] =3D "EBUSY"; - > #endif - > -#ifdef ECANCELED - > +#if defined(ECANCELED) && !defined(GNULIB_defined_ECANCELED) - > errcode[ECANCELED] =3D "ECANCELED"; - > #endif - > #ifdef ECHILD - > @@ -103,7 +103,7 @@ init_errcode(void) - > #ifdef ECOMM - > errcode[ECOMM] =3D "ECOMM"; - > #endif - > -#ifdef ECONNABORTED - > +#if defined(ECONNABORTED) && !defined(GNULIB_defined_ECONABORTED) - > errcode[ECONNABORTED] =3D "ECONNABORTED"; - > #endif - > #ifdef ECONNREFUSED - > @@ -126,7 +126,7 @@ init_errcode(void) - > #ifdef EDOM - > errcode[EDOM] =3D "EDOM"; - > #endif - > -#ifdef EDQUOT - > +#if defined(EDQUOT) && !defined(GNULIB_defined_EDQUOT) - > errcode[EDQUOT] =3D "EDQUOT"; - > #endif - > #ifdef EEXIST - > @@ -147,7 +147,7 @@ init_errcode(void) - > #ifdef EIDRM - > errcode[EIDRM] =3D "EIDRM"; - > #endif - > -#ifdef EILSEQ - > +#if defined(EILSEQ) && !defined(GNULIB_defined_EILSEQ) - > errcode[EILSEQ] =3D "EILSEQ"; - > #endif - > #ifdef EINPROGRESS - > @@ -222,7 +222,7 @@ init_errcode(void) - > #ifdef EMSGSIZE - > errcode[EMSGSIZE] =3D "EMSGSIZE"; - > #endif - > -#ifdef EMULTIHOP - > +#if defined(EMULTIHOP) && !defined(GNULIB_defined_EMULTIHOP) - > errcode[EMULTIHOP] =3D "EMULTIHOP"; - > #endif - > #ifdef ENAMETOOLONG - > @@ -231,7 +231,7 @@ init_errcode(void) - > #ifdef ENETDOWN - > errcode[ENETDOWN] =3D "ENETDOWN"; - > #endif - > -#ifdef ENETRESET - > +#if defined(ENETRESET) && !defined(GNULIB_defined_ENETRESET) - > errcode[ENETRESET] =3D "ENETRESET"; - > #endif - > #ifdef ENETUNREACH - > @@ -261,7 +261,7 @@ init_errcode(void) - > #ifdef ENOLCK - > errcode[ENOLCK] =3D "ENOLCK"; - > #endif - > -#ifdef ENOLINK - > +#if defined(ENOLINK) && !defined(GNULIB_defined_ENOLINK) - > errcode[ENOLINK] =3D "ENOLINK"; - > #endif - > #ifdef ENOMEDIUM - > @@ -270,7 +270,7 @@ init_errcode(void) - > #ifdef ENOMEM - > errcode[ENOMEM] =3D "ENOMEM"; - > #endif - > -#ifdef ENOMSG - > +#if defined(ENOMSG) && !defined(GNULIB_defined_ENOMSG) - > errcode[ENOMSG] =3D "ENOMSG"; - > #endif - > #ifdef ENONET - > @@ -309,7 +309,7 @@ init_errcode(void) - > #ifdef ENOTSOCK - > errcode[ENOTSOCK] =3D "ENOTSOCK"; - > #endif - > -#ifdef ENOTSUP - > +#if defined(ENOTSUP) && !defined(GNULIB_defined_ENOTSUP) - > errcode[ENOTSUP] =3D "ENOTSUP"; - > #endif - > #ifdef ENOTTY - > @@ -324,7 +324,7 @@ init_errcode(void) - > #ifdef EOPNOTSUPP - > errcode[EOPNOTSUPP] =3D "EOPNOTSUPP"; - > #endif - > -#ifdef EOVERFLOW - > +#if defined(EOVERFLOW) && !defined(GNULIB_defined_EOVERFLOW) - > errcode[EOVERFLOW] =3D "EOVERFLOW"; - > #endif - > #ifdef EPERM - > @@ -336,7 +336,7 @@ init_errcode(void) - > #ifdef EPIPE - > errcode[EPIPE] =3D "EPIPE"; - > #endif - > -#ifdef EPROTO - > +#if defined(EPROTO) && !defined(GNULIB_defined_EPROTO) - > errcode[EPROTO] =3D "EPROTO"; - > #endif - > #ifdef EPROTONOSUPPORT - > @@ -375,7 +375,7 @@ init_errcode(void) - > #ifdef ESRCH - > errcode[ESRCH] =3D "ESRCH"; - > #endif - > -#ifdef ESTALE - > +#if defined(ESTALE) && !defined(GNULIB_defined_ESTALE) - > errcode[ESTALE] =3D "ESTALE"; - > #endif - > #ifdef ESTRPIPE - > @@ -408,10 +408,10 @@ init_errcode(void) - > #ifdef EXFULL - > errcode[EXFULL] =3D "EXFULL"; - > #endif - > -#ifdef EOWNERDEAD - > +#if defined(EOWNERDEAD) && !defined(GNULIB_defined_EOWNERDEAD) - > errcode[EOWNERDEAD] =3D "EOWNERDEAD"; - > #endif - > -#ifdef ENOTRECOVERABLE - > +#if defined(ENOTRECOVERABLE) && !defined(GNULIB_defined_ENOTRECOVERABLE) - > errcode[ENOTRECOVERABLE] =3D "ENOTRECOVERABLE"; - > #endif - > #ifdef ERFKILL - >