diff options
| author | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-06 16:18:09 +0100 |
|---|---|---|
| committer | Denys Vlasenko <dvlasenk@redhat.com> | 2011-01-06 16:18:09 +0100 |
| commit | d108d7d2fbe0b178110295fd8335c258f699a5d4 (patch) | |
| tree | 3bebcc8c7f66a15383be577beb04300f6fe6e9af /src/lib | |
| parent | 6c7086f6c0086496a5a1ae9ab13fdbb310e070ba (diff) | |
| download | abrt-d108d7d2fbe0b178110295fd8335c258f699a5d4.tar.gz abrt-d108d7d2fbe0b178110295fd8335c258f699a5d4.tar.xz abrt-d108d7d2fbe0b178110295fd8335c258f699a5d4.zip | |
pass old pattern to ccpp hook and use it
abrtd:
instead of
"|/usr/libexec/abrt-ccpp-hook DEBUG_DUMPS_DIR %p %s %u %c",
sets coredump handler to
"|/usr/libexec/abrt-ccpp-hook DEBUG_DUMPS_DIR %s %c %p %u %g %t %h %e OLD_PATTERN"
abrt-ccpp-hook:
expands OLD_PATTERN using values of %s %c %p %u %g %t %h %e
and uses it as a name of "compat coredump".
Patch has a feature which prevents usage of kernel-truncated
OLD_PATTERN: it is passed as hex string *with terminating NUL*
(encoded as 00). If ccpp hook doesn't see 00, it refuses to use
OLD_PATTERN and uses string "core" instead.
Run tested. On a new kernel, passes up to 27 char long old pattern.
Longer patterns are still truncated.
This may be improved in future kernels.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/Makefile.am | 1 | ||||
| -rw-r--r-- | src/lib/binhex.c | 74 |
2 files changed, 75 insertions, 0 deletions
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index b02acb82..6d6c22bb 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -15,6 +15,7 @@ lib_LTLIBRARIES = \ libreport_la_SOURCES = \ xfuncs.c \ encbase64.c \ + binhex.c \ stdio_helpers.c \ hash_md5.c hash_md5.h \ hash_sha1.c hash_sha1.h \ diff --git a/src/lib/binhex.c b/src/lib/binhex.c new file mode 100644 index 00000000..1fcb7445 --- /dev/null +++ b/src/lib/binhex.c @@ -0,0 +1,74 @@ +/* + Copyright (C) 2010 ABRT team + Copyright (C) 2010 RedHat Inc + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 + as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ +#include "abrtlib.h" + +static const char hexdigits_locase[] = "0123456789abcdef"; + +/* Emit a string of hex representation of bytes */ +char *bin2hex(char *dst, const char *str, int count) +{ + while (count) { + unsigned char c = *str++; + /* put lowercase hex digits */ + *dst++ = hexdigits_locase[c >> 4]; + *dst++ = hexdigits_locase[c & 0xf]; + count--; + } + return dst; +} + +/* Convert "xxxxxxxx" hex string to binary, no more than COUNT bytes */ +char *hex2bin(char *dst, const char *str, int count) +{ + /* Parts commented out with // allow parsing + * of strings like "xx:x:x:xx:xx:xx:xxxxxx" + * (IPv6, ethernet addresses and the like). + */ + errno = EINVAL; + while (*str && count) { + uint8_t val; + uint8_t c; + + c = *str++; + if (isdigit(c)) + val = c - '0'; + else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') + val = (c|0x20) - ('a' - 10); + else + return NULL; + val <<= 4; + c = *str; + if (isdigit(c)) + val |= c - '0'; + else if ((c|0x20) >= 'a' && (c|0x20) <= 'f') + val |= (c|0x20) - ('a' - 10); + //else if (c == ':' || c == '\0') + // val >>= 4; + else + return NULL; + + *dst++ = val; + //if (c != '\0') + str++; + //if (*str == ':') + // str++; + count--; + } + errno = (*str ? ERANGE : 0); + return dst; +} |
