diff options
author | Ken Raeburn <raeburn@mit.edu> | 2007-06-29 01:01:24 +0000 |
---|---|---|
committer | Ken Raeburn <raeburn@mit.edu> | 2007-06-29 01:01:24 +0000 |
commit | f8369e867bcb6ff44d2ee12fc79070b869d41abd (patch) | |
tree | 93742abe35959d7f3897d6f3b43ca37921d59a82 /src/appl | |
parent | 0708ecde434afdabb8412d6af61a0c717af56abb (diff) | |
download | krb5-f8369e867bcb6ff44d2ee12fc79070b869d41abd.zip krb5-f8369e867bcb6ff44d2ee12fc79070b869d41abd.tar.gz krb5-f8369e867bcb6ff44d2ee12fc79070b869d41abd.tar.bz2 |
Attach format attributes to declarations of various message-formatting
routines under gcc. In a couple of routines, hard-code the preference
for using the vsnprintf paths instead of list-of-int-arguments hacks
now that we're assuming vsnprintf is available in other places.
Installed headers affected:
com_err.h (com_err, com_err_va)
ss.h (ss_error)
krb5.h (krb5_set_error_message, krb5_vset_error_message)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@19653 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/appl')
-rw-r--r-- | src/appl/gssftp/ftp/ftp_var.h | 6 | ||||
-rw-r--r-- | src/appl/gssftp/ftp/secure.h | 6 | ||||
-rw-r--r-- | src/appl/gssftp/ftpd/ftpd.c | 34 | ||||
-rw-r--r-- | src/appl/gssftp/ftpd/secure.h | 8 | ||||
-rw-r--r-- | src/appl/telnet/telnetd/ext.h | 18 | ||||
-rw-r--r-- | src/appl/telnet/telnetd/utility.c | 11 |
6 files changed, 44 insertions, 39 deletions
diff --git a/src/appl/gssftp/ftp/ftp_var.h b/src/appl/gssftp/ftp/ftp_var.h index 9baa047..39386ff 100644 --- a/src/appl/gssftp/ftp/ftp_var.h +++ b/src/appl/gssftp/ftp/ftp_var.h @@ -173,7 +173,11 @@ extern char *tail(); extern char *mktemp(); #endif -extern int command(char *, ...); +extern int command(char *, ...) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 1, 2))) +#endif + ; char *remglob (char **, int); int another (int *, char ***, char *); diff --git a/src/appl/gssftp/ftp/secure.h b/src/appl/gssftp/ftp/secure.h index 5d1bd0b..011d745 100644 --- a/src/appl/gssftp/ftp/secure.h +++ b/src/appl/gssftp/ftp/secure.h @@ -12,4 +12,8 @@ int secure_write (int, unsigned char *, unsigned int); int secure_read (int, char *, unsigned int); void secure_gss_error (OM_uint32 maj_stat, OM_uint32 min_stat, char *s); -void secure_error(char *, ...); +void secure_error(char *, ...) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 1, 2))) +#endif + ; diff --git a/src/appl/gssftp/ftpd/ftpd.c b/src/appl/gssftp/ftpd/ftpd.c index 94b40dc..708bfde 100644 --- a/src/appl/gssftp/ftpd/ftpd.c +++ b/src/appl/gssftp/ftpd/ftpd.c @@ -1464,26 +1464,15 @@ dataconn(name, size, fmode) * XXX callers need to limit total length of output string to * FTP_BUFSIZ */ -#ifdef STDARG void secure_error(char *fmt, ...) -#else -/* VARARGS1 */ -void -secure_error(fmt, p1, p2, p3, p4, p5) - char *fmt; -#endif { char buf[FTP_BUFSIZ]; -#ifdef STDARG va_list ap; va_start(ap, fmt); - vsprintf(buf, fmt, ap); + vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); -#else - sprintf(buf, fmt, p1, p2, p3, p4, p5); -#endif reply(535, "%s", buf); syslog(LOG_ERR, "%s", buf); } @@ -2612,36 +2601,29 @@ static char *onefile[] = { * XXX callers need to limit total length of output string to * FTP_BUFSIZ */ -#ifdef STDARG static int secure_fprintf(FILE *stream, char *fmt, ...) -#else -static int -secure_fprintf(stream, fmt, p1, p2, p3, p4, p5) -FILE *stream; -char *fmt; +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 2, 3))) #endif + ; + +static int +secure_fprintf(FILE *stream, char *fmt, ...) { char s[FTP_BUFSIZ]; int rval; -#ifdef STDARG va_list ap; va_start(ap, fmt); if (dlevel == PROT_C) rval = vfprintf(stream, fmt, ap); else { - vsprintf(s, fmt, ap); + vsnprintf(s, sizeof(s), fmt, ap); rval = secure_write(fileno(stream), s, strlen(s)); } va_end(ap); return(rval); -#else - if (dlevel == PROT_C) - return(fprintf(stream, fmt, p1, p2, p3, p4, p5)); - sprintf(s, fmt, p1, p2, p3, p4, p5); - return(secure_write(fileno(stream), s, strlen(s))); -#endif } void diff --git a/src/appl/gssftp/ftpd/secure.h b/src/appl/gssftp/ftpd/secure.h index 97fd0c7..21b7ff8 100644 --- a/src/appl/gssftp/ftpd/secure.h +++ b/src/appl/gssftp/ftpd/secure.h @@ -12,8 +12,8 @@ int secure_write (int, unsigned char *, unsigned int); int secure_read (int, char *, unsigned int); void secure_gss_error (OM_uint32 maj_stat, OM_uint32 min_stat, char *s); -#if defined(STDARG) || (defined(__STDC__) && ! defined(VARARGS)) || defined(HAVE_STDARG_H) -void secure_error(char *, ...); -#else -void secure_error(); +void secure_error(char *, ...) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 1, 2))) #endif + ; diff --git a/src/appl/telnet/telnetd/ext.h b/src/appl/telnet/telnetd/ext.h index 5d4f8e1..3a0d103 100644 --- a/src/appl/telnet/telnetd/ext.h +++ b/src/appl/telnet/telnetd/ext.h @@ -184,9 +184,21 @@ extern void willoption (int), wontoption (int); -extern void netprintf (const char *, ...); -extern void netprintf_urg (const char *fmt, ...); -extern void netprintf_noflush (const char *fmt, ...); +extern void netprintf (const char *, ...) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 1, 2))) +#endif + ; +extern void netprintf_urg (const char *fmt, ...) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 1, 2))) +#endif + ; +extern void netprintf_noflush (const char *fmt, ...) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 1, 2))) +#endif + ; extern int netwrite (const unsigned char *, size_t); extern void netputs (const char *); diff --git a/src/appl/telnet/telnetd/utility.c b/src/appl/telnet/telnetd/utility.c index f4568ec..a091d08 100644 --- a/src/appl/telnet/telnetd/utility.c +++ b/src/appl/telnet/telnetd/utility.c @@ -393,6 +393,13 @@ netflush() */ static void netprintf_ext(int noflush, int seturg, const char *fmt, va_list args) +#if !defined(__cplusplus) && (__GNUC__ > 2) + __attribute__((__format__(__printf__, 3, 0))) +#endif + ; + +static void +netprintf_ext(int noflush, int seturg, const char *fmt, va_list args) { size_t remain; size_t maxoutlen; @@ -412,11 +419,7 @@ netprintf_ext(int noflush, int seturg, const char *fmt, va_list args) if (maxoutlen >= sizeof(buf)) return; /* highly unlikely */ -#ifdef HAVE_VSNPRINTF len = vsnprintf(buf, sizeof(buf), fmt, args); -#else - len = vsprintf(buf, fmt, args); /* XXX need to fix for SunOS? */ -#endif /* * The return value from sprintf()-like functions may be the |