Module: ngircd.git
Branch: master
Commit: 8ae2cdfce9f8ba75fe72d65603d4c05c87f6d9c2
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=8ae2cdfc…
Author: Alexander Barton <alex(a)barton.de>
Date: Wed Jan 8 14:18:09 2014 +0100
Send "fake '*' key" in "MODE -k" replies
According to RFC 2812 3.2.3 "Channel mode message" and the examples
there, it looks like clients should use "MODE -k <key>" to unset channel
keys; and that's how other servers and services behave and do expect it.
(But please note that this is NOT the case for "MODE -l"!)
In the end, it doesn't make sense to specify a key when UNsetting it at
all, and different services behave diffrently when clients do not send
the currently set key to unset it - some ignore such calls, for example!
But this implementation is quite relaxed, it accepts any key when
unsetting channel mode "k" and even accepts no key at all. But the reply
will always include an "*" character for every "-k" parameter.
---
src/ngircd/irc-mode.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ngircd/irc-mode.c b/src/ngircd/irc-mode.c
index a29ed23..a59f085 100644
--- a/src/ngircd/irc-mode.c
+++ b/src/ngircd/irc-mode.c
@@ -582,9 +582,13 @@ Channel_Mode(CLIENT *Client, REQUEST *Req, CLIENT *Origin, CHANNEL *Channel)
goto chan_exit;
if (!set) {
if (is_oper || is_machine || is_owner ||
- is_admin || is_op || is_halfop)
+ is_admin || is_op || is_halfop) {
x[0] = *mode_ptr;
- else
+ if (Channel_HasMode(Channel, 'k'))
+ strlcpy(argadd, "*", sizeof(argadd));
+ if (arg_arg > mode_arg)
+ arg_arg++;
+ } else
connected = IRC_WriteErrClient(Origin,
ERR_CHANOPRIVSNEEDED_MSG,
Client_ID(Origin),
Module: ngircd.git
Branch: master
Commit: e2b85ccde360ccc389afb0af12d5d75f0549f666
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=e2b85ccd…
Author: Alexander Barton <alex(a)barton.de>
Date: Sun Jan 5 00:48:31 2014 +0100
platformtest.sh: don't use "test -e", it isn't portable
---
contrib/platformtest.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/platformtest.sh b/contrib/platformtest.sh
index 6a1dc71..76f4169 100755
--- a/contrib/platformtest.sh
+++ b/contrib/platformtest.sh
@@ -1,7 +1,7 @@
#!/bin/sh
#
# ngIRCd -- The Next Generation IRC Daemon
-# Copyright (c)2001-2013 Alexander Barton (alex(a)barton.de) and Contributors
+# Copyright (c)2001-2014 Alexander Barton (alex(a)barton.de) and Contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -65,7 +65,7 @@ if [ -d .git ]; then
fi
echo "$NAME: Checking for \"./configure\" script ..."
-if [ ! -e ./configure ]; then
+if [ ! -r ./configure ]; then
echo "$NAME: Running \"./autogen.sh\" ..."
[ -n "$VERBOSE" ] && ./autogen.sh || ./autogen.sh >/dev/null
fi
Module: ngircd.git
Branch: master
Commit: 5d88030bd1a197041f84530a88c2590e6bb1bbb1
URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=5d88030b…
Author: Alexander Barton <alex(a)barton.de>
Date: Sat Jan 4 23:57:05 2014 +0100
Support non-standard vsnprintf() return code
C99 states that vsnprintf() "returns the number of characters that
would have been printed if the n were unlimited"; but according to the
Linux manual page "glibc until 2.0.6 would return -1 when the output
was truncated" -- so we have to handle both cases ...
---
src/ngircd/conn.c | 13 +++++++++++--
src/portab/portabtest.c | 25 ++++++++++++++++++++++---
2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index 3f447c6..fef568e 100644
--- a/src/ngircd/conn.c
+++ b/src/ngircd/conn.c
@@ -1,6 +1,6 @@
/*
* ngIRCd -- The Next Generation IRC Daemon
- * Copyright (c)2001-2013 Alexander Barton (alex(a)barton.de) and Contributors.
+ * Copyright (c)2001-2014 Alexander Barton (alex(a)barton.de) and Contributors.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -984,6 +984,7 @@ va_dcl
size_t len;
bool ok;
va_list ap;
+ int r;
assert( Idx > NONE );
assert( Format != NULL );
@@ -993,7 +994,8 @@ va_dcl
#else
va_start( ap );
#endif
- if (vsnprintf( buffer, COMMAND_LEN - 2, Format, ap ) >= COMMAND_LEN - 2 ) {
+ r = vsnprintf(buffer, COMMAND_LEN - 2, Format, ap);
+ if (r >= COMMAND_LEN - 2 || r == -1) {
/*
* The string that should be written to the socket is longer
* than the allowed size of COMMAND_LEN bytes (including both
@@ -1014,6 +1016,13 @@ va_dcl
* an other server only routing the message!), so the only
* option left is to shorten the string and to hope that the
* result is still somewhat useful ...
+ *
+ * Note:
+ * C99 states that vsnprintf() "returns the number of characters
+ * that would have been printed if the n were unlimited"; but
+ * according to the Linux manual page "glibc until 2.0.6 would
+ * return -1 when the output was truncated" -- so we have to
+ * handle both cases ...
* -alex-
*/
diff --git a/src/portab/portabtest.c b/src/portab/portabtest.c
index 9e6bd22..b104739 100644
--- a/src/portab/portabtest.c
+++ b/src/portab/portabtest.c
@@ -139,16 +139,35 @@ va_dcl
{
char str[5];
va_list ap;
+ int r;
#ifdef PROTOTYPES
va_start(ap, Format);
#else
va_start(ap);
#endif
- if (vsnprintf(str, sizeof(str), Format, ap) != Len)
- Panic("vsnprintf return code");
+ r = vsnprintf(str, sizeof(str), Format, ap);
va_end(ap);
-
+ if (r != Len) {
+ /* C99 states that vsnprintf() "returns the number of
+ * characters that would have been printed if the n were
+ * unlimited", but according to the Linux manual page "glibc
+ * until 2.0.6 would return -1 when the output was truncated",
+ * and other implementations (libUTIL on A/UX) even return the
+ * number of characters processed ... so we only test our own
+ * implementation and warn on errors otherwise :-/ */
+#ifdef HAVE_VSNPRINTF
+ fprintf(stderr,
+ "\n ** WARNING: The vsnprintf() function of this system isn't standard\n");
+ fprintf(stderr,
+ " ** conformant and returns a WRONG result: %d (should be %d)! The test\n",
+ r, Len);
+ fprintf(stderr,
+ " ** result has been ignored but may lead to errors during execution!\n\n");
+#else
+ Panic("vsnprintf return code");
+#endif
+ }
if (str[4] != '\0')
Panic("vsnprintf NULL byte");
if (strlen(str) != 4)