From 26a12994911b71b41fa46e4f2ca5d28b31c6c4d3 Mon Sep 17 00:00:00 2001 From: Markus Friedl Date: Fri, 5 May 2000 18:53:43 +0000 Subject: remote trailing comments before calling __b64_pton --- usr.bin/ssh/key.c | 4 ++++ usr.bin/ssh/radix.c | 3 ++- usr.bin/ssh/uuencode.c | 18 ++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/ssh/key.c b/usr.bin/ssh/key.c index 572317a6416..ae355a3fcdc 100644 --- a/usr.bin/ssh/key.c +++ b/usr.bin/ssh/key.c @@ -255,6 +255,10 @@ key_read(Key *ret, char **cpp) len = 2*strlen(cp); blob = xmalloc(len); n = uudecode(cp, blob, len); + if (n < 0) { + error("uudecode %s failed", cp); + return 0; + } k = dsa_key_from_blob(blob, n); if (k == NULL) return 0; diff --git a/usr.bin/ssh/radix.c b/usr.bin/ssh/radix.c index 4a8e9df069b..03377334415 100644 --- a/usr.bin/ssh/radix.c +++ b/usr.bin/ssh/radix.c @@ -131,7 +131,8 @@ radix_to_creds(const char *buf, CREDENTIALS *creds) char version; char temp[2048]; - if (!(len = uudecode(buf, (unsigned char *)temp, sizeof(temp)))) + len = uudecode(buf, (unsigned char *)temp, sizeof(temp)); + if (len < 0) return 0; p = temp; diff --git a/usr.bin/ssh/uuencode.c b/usr.bin/ssh/uuencode.c index a67040b2fb1..fc84d5a5830 100644 --- a/usr.bin/ssh/uuencode.c +++ b/usr.bin/ssh/uuencode.c @@ -10,13 +10,27 @@ int uuencode(unsigned char *src, unsigned int srclength, char *target, size_t targsize) { - return b64_ntop(src, srclength, target, targsize); + return __b64_ntop(src, srclength, target, targsize); } int uudecode(const char *src, unsigned char *target, size_t targsize) { - return b64_pton(src, target, targsize); + int len; + char *encoded, *p; + + /* copy the 'readonly' source */ + encoded = xstrdup(src); + /* skip whitespace and data */ + for (p = encoded; *p == ' ' || *p == '\t'; p++) + ; + for (; *p != '\0' && *p != ' ' && *p != '\t'; p++) + ; + /* and remote trailing whitespace because __b64_pton needs this */ + *p = '\0'; + len = __b64_pton(encoded, target, targsize); + xfree(encoded); + return len; } void -- cgit v1.2.3