diff --git a/appl/ftp/ftp/gssapi.c b/appl/ftp/ftp/gssapi.c index 9b2d9ee7b..8e3a40d84 100644 --- a/appl/ftp/ftp/gssapi.c +++ b/appl/ftp/ftp/gssapi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998 - 2003 Kungliga Tekniska Högskolan + * Copyright (c) 1998 - 2005 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -306,7 +306,7 @@ import_name(const char *kname, const char *host, gss_name_t *target_name) gss_buffer_desc name; name.length = asprintf((char**)&name.value, "%s@%s", kname, host); - if (name.value == NULL) { + if (name.length == -1) { printf("Out of memory\n"); return AUTH_ERROR; } diff --git a/appl/ftp/ftp/security.c b/appl/ftp/ftp/security.c index d9a0cde13..8b7fcbced 100644 --- a/appl/ftp/ftp/security.c +++ b/appl/ftp/ftp/security.c @@ -310,8 +310,11 @@ sec_vfprintf2(FILE *f, const char *fmt, va_list ap) if(data_prot == prot_clear) return vfprintf(f, fmt, ap); else { - vasprintf(&buf, fmt, ap); - ret = buffer_write(&out_buffer, buf, strlen(buf)); + int len; + len = vasprintf(&buf, fmt, ap); + if (len == -1) + return len; + ret = buffer_write(&out_buffer, buf, len); free(buf); return ret; } @@ -379,7 +382,10 @@ sec_vfprintf(FILE *f, const char *fmt, va_list ap) if(!sec_complete) return vfprintf(f, fmt, ap); - vasprintf(&buf, fmt, ap); + if (vasprintf(&buf, fmt, ap) == -1) { + printf("Failed to allocate command.\n"); + return -1; + } len = (*mech->encode)(app_data, buf, strlen(buf), command_prot, &enc); free(buf); if(len < 0) { diff --git a/appl/ftp/ftpd/ftpd.c b/appl/ftp/ftpd/ftpd.c index 81e91eba3..f7ce1e6a1 100644 --- a/appl/ftp/ftpd/ftpd.c +++ b/appl/ftp/ftpd/ftpd.c @@ -1023,9 +1023,10 @@ retrieve(const char *cmd, char *name) *tail = c; if (p->rev_cmd != NULL) { char *ext; + int ret; - asprintf(&ext, "%s%s", name, p->ext); - if (ext != NULL) { + ret = asprintf(&ext, "%s%s", name, p->ext); + if (ret != -1) { if (access(ext, R_OK) == 0) { snprintf (line, sizeof(line), p->rev_cmd, ext); diff --git a/appl/ftp/ftpd/gss_userok.c b/appl/ftp/ftpd/gss_userok.c index 4bde47e60..6da50ee98 100644 --- a/appl/ftp/ftpd/gss_userok.c +++ b/appl/ftp/ftpd/gss_userok.c @@ -105,8 +105,7 @@ gss_userok(void *app_data, char *username) chown (ticketfile, kpw->pw_uid, kpw->pw_gid); - asprintf(&k5ccname, "FILE:%s", ticketfile); - if (k5ccname) { + if (asprintf(&k5ccname, "FILE:%s", ticketfile) != -1) { esetenv ("KRB5CCNAME", k5ccname, 1); } afslog(NULL, 1);