From 057ac0c2762a878a369eefa0beb96ce66f614af5 Mon Sep 17 00:00:00 2001 From: Assar Westerlund Date: Fri, 5 Dec 1997 02:36:03 +0000 Subject: [PATCH] check return value of base64_encode git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4119 ec53bebd-3082-4978-b11e-865c3cabbd6b --- appl/ftp/ftp/kauth.c | 6 +++++- appl/ftp/ftp/krb4.c | 13 ++++++++++--- appl/ftp/ftpd/kauth.c | 5 ++++- appl/ftp/ftpd/krb4.c | 14 ++++++++++---- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/appl/ftp/ftp/kauth.c b/appl/ftp/ftp/kauth.c index 264966a06..1295d8cd1 100644 --- a/appl/ftp/ftp/kauth.c +++ b/appl/ftp/ftp/kauth.c @@ -121,7 +121,11 @@ kauth(int argc, char **argv) memset(key, 0, sizeof(key)); memset(schedule, 0, sizeof(schedule)); memset(passwd, 0, sizeof(passwd)); - base64_encode(tktcopy.dat, tktcopy.length, &p); + if(base64_encode(tktcopy.dat, tktcopy.length, &p) < 0) { + printf("Out of memory base64-encoding.\n"); + code = -1; + return; + } memset (tktcopy.dat, 0, tktcopy.length); ret = command("SITE KAUTH %s %s", name, p); free(p); diff --git a/appl/ftp/ftp/krb4.c b/appl/ftp/ftp/krb4.c index c26f19e4a..7727458e1 100644 --- a/appl/ftp/ftp/krb4.c +++ b/appl/ftp/ftp/krb4.c @@ -447,7 +447,11 @@ do_klogin(char *host) return ret; } - base64_encode(krb4_adat.dat, krb4_adat.length, &p); + if(base64_encode(krb4_adat.dat, krb4_adat.length, &p) < 0) { + printf("Out of memory base64-encoding.\n"); + verbose = old_verbose; + return -1; + } ret = command("ADAT %s", p); free(p); @@ -502,7 +506,8 @@ krb4_quit(void) data_prot = 0; } -int krb4_write_enc(FILE *F, char *fmt, va_list ap) +int +krb4_write_enc(FILE *F, char *fmt, va_list ap) { int len; char *p; @@ -512,7 +517,9 @@ int krb4_write_enc(FILE *F, char *fmt, va_list ap) vsnprintf(buf, sizeof(buf), fmt, ap); len = krb_mk_priv(buf, enc, strlen(buf), schedule, &key, &myctladdr, &hisctladdr); - base64_encode(enc, len, &p); + if(base64_encode(enc, len, &p) < 0) { + return -1; + } fprintf(F, "ENC %s", p); free (p); diff --git a/appl/ftp/ftpd/kauth.c b/appl/ftp/ftpd/kauth.c index 6afb443ad..9c1c9e26e 100644 --- a/appl/ftp/ftpd/kauth.c +++ b/appl/ftp/ftpd/kauth.c @@ -231,7 +231,10 @@ kauth(char *principal, char *ticket) reply(500, "Kerberos error: %s.", krb_get_err_text(ret)); return; } - base64_encode(cip.dat, cip.length, &p); + if(base64_encode(cip.dat, cip.length, &p) < 0) { + reply(500, "Out of memory while base64-encoding."); + return; + } reply(300, "P=%s T=%s", krb_unparse_name(&pr), p); free(p); memset(&cip, 0, sizeof(cip)); diff --git a/appl/ftp/ftpd/krb4.c b/appl/ftp/ftpd/krb4.c index 428784857..cd804ac9e 100644 --- a/appl/ftp/ftpd/krb4.c +++ b/appl/ftp/ftpd/krb4.c @@ -122,7 +122,10 @@ int krb4_adat(char *auth) reply(535, "Error creating reply: %s.", strerror(errno)); return -1; } - base64_encode(msg, len, &p); + if(base64_encode(msg, len, &p) < 0) { + reply(535, "Out of memory base64-encoding."); + return -1; + } reply(235, "ADAT=%s", p); auth_complete = 1; free(p); @@ -364,9 +367,12 @@ krb4_vprintf(const char *fmt, va_list ap) len = 0; /* XXX */ code = 631; } - base64_encode(enc, len, &p); - fprintf(stdout, "%d %s\r\n", code, p); + if(base64_encode(enc, len, &p) < 0) { + ; /* XXX */ + } else { + fprintf(stdout, "%d %s\r\n", code, p); + free(p); + } free(enc); - free(p); return 0; } -- 2.11.4.GIT