summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2010-08-05 13:14:58 +0200
committerKarel Zak <kzak@redhat.com>2011-01-03 12:28:40 +0100
commit7a539b29af600e1adb1f48f4772a41c2e5e95e42 (patch)
treed8caa327c766c3ddf0cc09aff0314bb9ca025611 /lib
parentbe1a5180596aa3a413e9c8047d0d25f4704756ef (diff)
downloadutil-linux-old-7a539b29af600e1adb1f48f4772a41c2e5e95e42.tar.gz
lib: fix mange() and unmangle() to handle NULL
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/mangle.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/mangle.c b/lib/mangle.c
index c40e67ba..e320cfb7 100644
--- a/lib/mangle.c
+++ b/lib/mangle.c
@@ -21,6 +21,9 @@ char *mangle(const char *s)
char *ss, *sp;
int n;
+ if (!s)
+ return NULL;
+
n = strlen(s);
ss = sp = malloc(4*n+1);
if (!sp)
@@ -48,6 +51,9 @@ void unmangle_to_buffer(const char *s, char *buf, size_t len)
{
size_t sz = 0;
+ if (!s)
+ return;
+
while(*s && sz < len - 1) {
if (*s == '\\' && sz + 4 < len - 1 && isoctal(s[1]) &&
isoctal(s[2]) && isoctal(s[3])) {
@@ -79,6 +85,9 @@ char *unmangle(const char *s)
const char *end;
size_t sz;
+ if (!s)
+ return NULL;
+
end = skip_nonspaces(s);
sz = end - s + 1;