From: Ezra Peisach Date: Thu, 17 Aug 2000 16:01:38 +0000 (+0000) Subject: * domacro.c: Compiler warning cleanups and fix the overflow fix to X-Git-Tag: krb5-1.3-alpha1~1918 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a0dc06a1445684068eed4088712554847428e622;p=krb5.git * domacro.c: Compiler warning cleanups and fix the overflow fix to index the proper array. * cmds.c, cmdtab.c, ftp.c, ftp_var.h, getpass.c, glob.c, main.c, radix.c, ruserpass.c, secure.c, secure.h: Compiler warning cleanups including providing prototypes, cleanup of assignments in conditionals, including unistd.h and stdlib.h (if present), declaring local functions as static. * Makefile.in: Do not compile pclose.c - the code is not used. About 600 warnings down.... git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12622 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/gssftp/ftp/ChangeLog b/src/appl/gssftp/ftp/ChangeLog index a5d22653b..ca10ff8f4 100644 --- a/src/appl/gssftp/ftp/ChangeLog +++ b/src/appl/gssftp/ftp/ChangeLog @@ -1,3 +1,16 @@ +2000-08-17 Ezra Peisach + + * domacro.c: Compiler warning cleanups and fix the overflow fix to + index the proper array. + + * cmds.c, cmdtab.c, ftp.c, ftp_var.h, getpass.c, glob.c, main.c, + radix.c, ruserpass.c, secure.c, secure.h: Compiler warning + cleanups including providing prototypes, cleanup of assignments in + conditionals, including unistd.h and stdlib.h (if present), + declaring local functions as static. + + * Makefile.in: Do not compile pclose.c - the code is not used. + 2000-05-11 Nalin Dahyabhai * domacro.c (domacro): Don't overflow "line2" diff --git a/src/appl/gssftp/ftp/Makefile.in b/src/appl/gssftp/ftp/Makefile.in index d9d981863..5739c8fa0 100644 --- a/src/appl/gssftp/ftp/Makefile.in +++ b/src/appl/gssftp/ftp/Makefile.in @@ -11,11 +11,11 @@ PROG_RPATH=$(KRB5_LIBDIR) SRCS = $(srcdir)/cmds.c $(srcdir)/cmdtab.c $(srcdir)/domacro.c \ $(srcdir)/ftp.c $(srcdir)/getpass.c $(srcdir)/glob.c \ - $(srcdir)/main.c $(srcdir)/pclose.c $(srcdir)/radix.c \ + $(srcdir)/main.c $(srcdir)/radix.c \ $(srcdir)/ruserpass.c $(srcdir)/secure.c -OBJS = cmds.o cmdtab.o domacro.o ftp.o getpass.o glob.o main.o pclose.o \ +OBJS = cmds.o cmdtab.o domacro.o ftp.o getpass.o glob.o main.o \ radix.o ruserpass.o secure.o LOCALINCLUDES = -I$(srcdir)/.. -I$(srcdir) @KRB4_INCLUDES@ @@ -39,7 +39,7 @@ install:: done ftp.o cmds.o main.o: $(srcdir)/../arpa/ftp.h -ftp.o cmds.o cmdtab.o domacro.o main.o ruserpass.o: $(srcdir)/ftp_var.h +ftp.o cmds.o cmdtab.o domacro.o main.o ruserpass.o: $(srcdir)/ftp_var.h secure.o: secure.h cmds.o: $(srcdir)/cmds.c diff --git a/src/appl/gssftp/ftp/cmds.c b/src/appl/gssftp/ftp/cmds.c index 0006e4fc5..ca354be31 100644 --- a/src/appl/gssftp/ftp/cmds.c +++ b/src/appl/gssftp/ftp/cmds.c @@ -38,6 +38,12 @@ static char sccsid[] = "@(#)cmds.c 5.26 (Berkeley) 3/5/91"; /* * FTP User Program -- Command Routines. */ +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif #include #include #include @@ -66,7 +72,6 @@ static char sccsid[] = "@(#)cmds.c 5.26 (Berkeley) 3/5/91"; typedef sigtype (*sig_t)(); extern char *globerr; -extern char **ftpglob(); extern char *home; extern char *remglob(); extern char *getenv(); @@ -80,23 +85,31 @@ extern char reply_string[]; char *mname; jmp_buf jabort; -char *dotrans(), *domap(); extern char *auth_type; extern int do_auth(); +static int globulize PROTOTYPE((char **)); +static int confirm PROTOTYPE((char *, char *)); +static int getit PROTOTYPE((int, char **, int, char *)); +static sigtype mabort PROTOTYPE((int)); +static void quote1 PROTOTYPE((char *, int, char **)); +static char *dotrans PROTOTYPE((char *)); +static char *domap PROTOTYPE((char *)); + /* * `Another' gets another argument, and stores the new argc and argv. * It reverts to the top level (via main.c's intr()) on EOF/error. * * Returns false if no new arguments have been added. */ +int another(pargc, pargv, prompt) int *pargc; char ***pargv; char *prompt; { - int len = strlen(line), ret; + int len = strlen(line), ret; extern sig_t intr(); if (len >= sizeof(line) - 3) { @@ -105,7 +118,7 @@ another(pargc, pargv, prompt) } printf("(%s) ", prompt); line[len++] = ' '; - if (fgets(&line[len], sizeof(line) - len, stdin) == NULL) + if (fgets(&line[len], (signed) sizeof(line) - len, stdin) == NULL) intr(); len += strlen(&line[len]); if (len > 0 && line[len - 1] == '\n') @@ -121,7 +134,7 @@ another(pargc, pargv, prompt) * Connect to peer server and * auto-login, if possible. */ -setpeer(argc, argv) +void setpeer(argc, argv) int argc; char *argv[]; { @@ -201,7 +214,7 @@ setpeer(argc, argv) if (debug == 0) verbose = -1; if (command("SYST") == COMPLETE && overbose) { - register char *cp, c; + register char *cp, c=0; cp = strchr(reply_string+4, ' '); if (cp == NULL) cp = strchr(reply_string+4, '\r'); @@ -257,10 +270,10 @@ struct levels { #ifndef NOENCRYPTION { "private", "P", PROT_P }, #endif - 0 + { 0, 0, 0} }; -char * +static char * getclevel() { register struct levels *p; @@ -269,7 +282,7 @@ getclevel() return(p->p_name); } -char * +static char * getdlevel() { register struct levels *p; @@ -287,7 +300,7 @@ char *plevel[] = { /* * Set control channel protection level. */ -setclevel(argc, argv) +void setclevel(argc, argv) char *argv[]; { register struct levels *p; @@ -339,6 +352,7 @@ setclevel(argc, argv) /* * Set data channel protection level. */ +void setdlevel(argc, argv) char *argv[]; { @@ -390,6 +404,7 @@ setdlevel(argc, argv) * Set clear command protection level. */ /*VARARGS*/ +void ccc() { plevel[1] = "clear"; @@ -400,6 +415,7 @@ ccc() * Set clear data protection level. */ /*VARARGS*/ +void setclear() { plevel[1] = "clear"; @@ -410,6 +426,7 @@ setclear() * Set safe data protection level. */ /*VARARGS*/ +void setsafe() { plevel[1] = "safe"; @@ -421,6 +438,7 @@ setsafe() * Set private data protection level. */ /*VARARGS*/ +void setprivate() { plevel[1] = "private"; @@ -439,10 +457,10 @@ struct types { { "image", "I", TYPE_I, 0 }, { "ebcdic", "E", TYPE_E, 0 }, { "tenex", "L", TYPE_L, bytename }, - 0 + { 0, 0 , 0, 0} }; -char * +static char * gettype() { register struct types *p; @@ -458,6 +476,7 @@ gettype() /* * Set transfer type. */ +void settype(argc, argv) int argc; char *argv[]; @@ -504,7 +523,7 @@ settype(argc, argv) * without changing our notion of the type for data transfers. * Used to change to and from ascii for listings. */ -changetype(newtype, show) +void changetype(newtype, show) int newtype, show; { register struct types *p; @@ -542,7 +561,7 @@ char *stype[] = { * Set binary transfer type. */ /*VARARGS*/ -setbinary() +void setbinary() { stype[1] = "binary"; settype(2, stype); @@ -552,7 +571,7 @@ setbinary() * Set ascii transfer type. */ /*VARARGS*/ -setascii() +void setascii() { stype[1] = "ascii"; settype(2, stype); @@ -562,13 +581,13 @@ setascii() * Set tenex transfer type. */ /*VARARGS*/ -settenex() +void settenex() { stype[1] = "tenex"; settype(2, stype); } -char * +static char * getmode() { return("stream"); @@ -578,7 +597,7 @@ getmode() * Set file transfer mode. */ /*ARGSUSED*/ -setmode(argc, argv) +void setmode(argc, argv) int argc; char *argv[]; { @@ -587,7 +606,7 @@ setmode(argc, argv) code = -1; } -char * +static char * getform() { return("non-print"); @@ -597,7 +616,7 @@ getform() * Set file transfer format. */ /*ARGSUSED*/ -setform(argc, argv) +void setform(argc, argv) int argc; char *argv[]; { @@ -606,7 +625,7 @@ setform(argc, argv) code = -1; } -char * +static char * getstruct() { return("file"); @@ -616,7 +635,7 @@ getstruct() * Set file transfer structure. */ /*ARGSUSED*/ -setstruct(argc, argv) +void setstruct(argc, argv) int argc; char *argv[]; { @@ -628,7 +647,7 @@ setstruct(argc, argv) /* * Send a single file. */ -put(argc, argv) +void put(argc, argv) int argc; char *argv[]; { @@ -676,16 +695,14 @@ usage: /* * Send multiple files. */ -mput(argc, argv) +void mput(argc, argv) int argc; char **argv; { - extern jmp_buf jabort; register int i; sig_t oldintr; int ointer; char *tp; - sigtype mabort(); if (argc < 2 && !another(&argc, &argv, "local-files")) { printf("usage: %s local-files\n", argv[0]); @@ -799,14 +816,14 @@ mput(argc, argv) mflag = 0; } -reget(argc, argv) +void reget(argc, argv) int argc; char *argv[]; { (void) getit(argc, argv, 1, "r+w"); } -get(argc, argv) +void get(argc, argv) int argc; char *argv[]; { @@ -816,10 +833,10 @@ get(argc, argv) /* * Receive one file. */ -getit(argc, argv, restartit, mode) +static int getit(argc, argv, restartit, rmode) int argc; char *argv[]; - char *mode; + char *rmode; { int loc = 0; char *oldargv1, *oldargv2; @@ -921,18 +938,17 @@ usage: } } - recvrequest("RETR", argv[2], argv[1], mode, + recvrequest("RETR", argv[2], argv[1], rmode, argv[1] != oldargv1 || argv[2] != oldargv2); restart_point = 0; return (0); } -sigtype +static sigtype mabort(sig) int sig; { int ointer; - extern jmp_buf jabort; printf("\n"); (void) fflush(stdout); @@ -952,15 +968,13 @@ mabort(sig) /* * Get multiple files. */ -mget(argc, argv) +void mget(argc, argv) int argc; char **argv; { - extern jmp_buf jabort; sig_t oldintr; int ointer; char *cp, *tp, *tp2, tmpbuf[MAXPATHLEN]; - sigtype mabort(); if (argc < 2 && !another(&argc, &argv, "remote-files")) { printf("usage: %s remote-files\n", argv[0]); @@ -1027,7 +1041,7 @@ remglob(argv,doswitch) static FILE *ftemp = NULL; static char **args; int oldverbose, oldhash; - char *cp, *mode; + char *cp, *rmode; if (!mflag) { if (!doglob) { @@ -1057,8 +1071,8 @@ remglob(argv,doswitch) if (doswitch) { pswitch(!proxy); } - for (mode = "w"; *++argv != NULL; mode = "a") - recvrequest ("NLST", temp, *argv, mode, 0); + for (rmode = "w"; *++argv != NULL; rmode = "a") + recvrequest ("NLST", temp, *argv, rmode, 0); if (doswitch) { pswitch(!proxy); } @@ -1079,7 +1093,7 @@ remglob(argv,doswitch) return (buf); } -char * +static char * onoff(bool) int bool; { @@ -1087,7 +1101,7 @@ onoff(bool) return (bool ? "on" : "off"); } -cstatus() +static void cstatus() { if (!connected) { printf(proxy ? "No proxy connection.\n" : "Not connected.\n"); @@ -1122,7 +1136,7 @@ cstatus() * Show status. */ /*ARGSUSED*/ -status(argc, argv) +void status(argc, argv) char *argv[]; { int i; @@ -1153,7 +1167,7 @@ status(argc, argv) * Set beep on cmd completed mode. */ /*VARARGS*/ -setbell() +void setbell() { bell = !bell; @@ -1165,7 +1179,7 @@ setbell() * Turn on packet tracing. */ /*VARARGS*/ -settrace() +void settrace() { trace = !trace; @@ -1177,7 +1191,7 @@ settrace() * Toggle hash mark printing during transfers. */ /*VARARGS*/ -sethash() +void sethash() { hash = !hash; @@ -1192,7 +1206,7 @@ sethash() * Turn on printing of server echo's. */ /*VARARGS*/ -setverbose() +void setverbose() { verbose = !verbose; @@ -1204,7 +1218,7 @@ setverbose() * Toggle PORT cmd use before each data connection. */ /*VARARGS*/ -setport() +void setport() { sendport = !sendport; @@ -1217,7 +1231,7 @@ setport() * during mget, mput, and mdelete. */ /*VARARGS*/ -setprompt() +void setprompt() { interactive = !interactive; @@ -1230,7 +1244,7 @@ setprompt() * on local file names. */ /*VARARGS*/ -setglob() +void setglob() { doglob = !doglob; @@ -1243,7 +1257,7 @@ setglob() * set level of debugging. */ /*VARARGS*/ -setdebug(argc, argv) +void setdebug(argc, argv) int argc; char *argv[]; { @@ -1271,7 +1285,7 @@ setdebug(argc, argv) * Set current working directory * on remote machine. */ -cd(argc, argv) +void cd(argc, argv) int argc; char *argv[]; { @@ -1292,7 +1306,7 @@ cd(argc, argv) * Set current working directory * on local machine. */ -lcd(argc, argv) +void lcd(argc, argv) int argc; char *argv[]; { @@ -1321,7 +1335,7 @@ lcd(argc, argv) /* * Delete a single file. */ -delete_file(argc, argv) +void delete_file(argc, argv) int argc; char *argv[]; { @@ -1337,15 +1351,13 @@ delete_file(argc, argv) /* * Delete multiple files. */ -mdelete(argc, argv) +void mdelete(argc, argv) int argc; char **argv; { - extern jmp_buf jabort; sig_t oldintr; int ointer; char *cp; - sigtype mabort(); if (argc < 2 && !another(&argc, &argv, "remote-files")) { printf("usage: %s remote-files\n", argv[0]); @@ -1380,7 +1392,7 @@ mdelete(argc, argv) /* * Rename a remote file. */ -renamefile(argc, argv) +void renamefile(argc, argv) int argc; char *argv[]; { @@ -1401,7 +1413,7 @@ usage: * Get a directory listing * of remote files. */ -ls(argc, argv) +void ls(argc, argv) int argc; char *argv[]; { @@ -1433,15 +1445,13 @@ ls(argc, argv) * Get a directory listing * of multiple remote files. */ -mls(argc, argv) +void mls(argc, argv) int argc; char **argv; { - extern jmp_buf jabort; sig_t oldintr; int ointer, i; - char *volatile cmd, mode[1], *dest; - sigtype mabort(); + char *volatile cmd, rmode[1], *dest; if (argc < 2 && !another(&argc, &argv, "remote-files")) goto usage; @@ -1465,8 +1475,8 @@ usage: oldintr = signal(SIGINT, mabort); (void) setjmp(jabort); for (i = 1; mflag && i < argc-1; ++i) { - *mode = (i == 1) ? 'w' : 'a'; - recvrequest(cmd, dest, argv[i], mode, 0); + *rmode = (i == 1) ? 'w' : 'a'; + recvrequest(cmd, dest, argv[i], rmode, 0); if (!mflag && fromatty) { ointer = interactive; interactive = 1; @@ -1484,17 +1494,17 @@ usage: * Do a shell escape */ /*ARGSUSED*/ -shell(argc, argv) +void shell(argc, argv) int argc; char **argv; { int pid; sig_t old1, old2; - char shellnam[40], *shell, *namep; + char shellnam[40], *shellprog, *namep; #ifdef WAIT_USES_INT - int status; + int w_status; #else - union wait status; + union wait w_status; #endif old1 = signal (SIGINT, SIG_IGN); @@ -1504,33 +1514,33 @@ shell(argc, argv) (void) close(pid); (void) signal(SIGINT, SIG_DFL); (void) signal(SIGQUIT, SIG_DFL); - shell = getenv("SHELL"); - if (shell == NULL) - shell = "/bin/sh"; - namep = strrchr(shell,'/'); + shellprog = getenv("SHELL"); + if (shellprog == NULL) + shellprog = "/bin/sh"; + namep = strrchr(shellprog,'/'); if (namep == NULL) - namep = shell; + namep = shellprog; (void) strcpy(shellnam,"-"); (void) strncat(shellnam, ++namep, sizeof(shellnam) - 1 - strlen(shellnam)); shellnam[sizeof(shellnam) - 1] = '\0'; if (strcmp(namep, "sh") != 0) shellnam[0] = '+'; if (debug) { - printf ("%s\n", shell); + printf ("%s\n", shellprog); (void) fflush (stdout); } if (argc > 1) { - execl(shell,shellnam,"-c",altarg,(char *)0); + execl(shellprog,shellnam,"-c",altarg,(char *)0); } else { - execl(shell,shellnam,(char *)0); + execl(shellprog,shellnam,(char *)0); } - perror(shell); + perror(shellprog); code = -1; exit(1); } if (pid > 0) - while (wait(&status) != pid) + while (wait(&w_status) != pid) ; (void) signal(SIGINT, old1); (void) signal(SIGQUIT, old2); @@ -1541,17 +1551,17 @@ shell(argc, argv) else { code = 0; } - return (0); + return; } /* * Send new user information (re-login) */ -user(argc, argv) +void user(argc, argv) int argc; char **argv; { - char acct[80], *mygetpass(); + char macct[80]; int n, aflag = 0; if (argc < 2) @@ -1559,7 +1569,7 @@ user(argc, argv) if (argc < 2 || argc > 4) { printf("usage: %s username [password] [account]\n", argv[0]); code = -1; - return (0); + return; } n = command("USER %s", argv[1]); if (n == COMPLETE) @@ -1582,28 +1592,29 @@ user(argc, argv) if (n == CONTINUE) { if (argc < 4) { printf("Account: "); (void) fflush(stdout); - (void) fgets(acct, sizeof(acct) - 1, stdin); - acct[strlen(acct) - 1] = '\0'; - argv[3] = acct; argc++; + (void) fgets(macct, sizeof(macct) - 1, stdin); + macct[strlen(macct) - 1] = '\0'; + argv[3] = macct; argc++; } n = command("ACCT %s", argv[3]); aflag++; } if (n != COMPLETE) { fprintf(stdout, "Login failed.\n"); - return (0); + /* code = -1;*/ + return; } if (!aflag && argc == 4) { (void) command("ACCT %s", argv[3]); } - return (1); + return; } /* * Print working directory. */ /*VARARGS*/ -pwd() +void pwd() { int oldverbose = verbose; @@ -1621,7 +1632,7 @@ pwd() /* * Make a directory. */ -makedir(argc, argv) +void makedir(argc, argv) int argc; char *argv[]; { @@ -1641,7 +1652,7 @@ makedir(argc, argv) /* * Remove a directory. */ -removedir(argc, argv) +void removedir(argc, argv) int argc; char *argv[]; { @@ -1661,7 +1672,7 @@ removedir(argc, argv) /* * Send a line, verbatim, to the remote machine. */ -quote(argc, argv) +void quote(argc, argv) int argc; char *argv[]; { @@ -1679,7 +1690,7 @@ quote(argc, argv) * is sent verbatim to the remote machine, except that the * word "SITE" is added at the front. */ -site(argc, argv) +void site(argc, argv) int argc; char *argv[]; { @@ -1696,7 +1707,7 @@ site(argc, argv) * Turn argv[1..argc) into a space-separated string, then prepend initial text. * Send the result as a one-line command and get response. */ -quote1(initial, argc, argv) +static void quote1(initial, argc, argv) char *initial; int argc; char **argv; @@ -1719,7 +1730,7 @@ quote1(initial, argc, argv) } } -do_chmod(argc, argv) +void do_chmod(argc, argv) int argc; char *argv[]; { @@ -1735,7 +1746,7 @@ usage: (void) command("SITE CHMOD %s %s", argv[1], argv[2]); } -do_umask(argc, argv) +void do_umask(argc, argv) int argc; char *argv[]; { @@ -1746,7 +1757,7 @@ do_umask(argc, argv) verbose = oldverbose; } -siteidle(argc, argv) +void siteidle(argc, argv) int argc; char *argv[]; { @@ -1760,7 +1771,7 @@ siteidle(argc, argv) /* * Ask the other side for help. */ -rmthelp(argc, argv) +void rmthelp(argc, argv) int argc; char *argv[]; { @@ -1775,7 +1786,7 @@ rmthelp(argc, argv) * Terminate session and exit. */ /*VARARGS*/ -quit() +void quit() { if (connected) @@ -1790,7 +1801,7 @@ quit() /* * Terminate session, but don't exit. */ -disconnect() +void disconnect() { extern FILE *cout; extern int data; @@ -1811,21 +1822,21 @@ disconnect() dlevel = PROT_C; } -confirm(cmd, file) +static int confirm(cmd, file) char *cmd, *file; { - char line[FTP_BUFSIZ]; + char mline[FTP_BUFSIZ]; if (!interactive) return (1); printf("%s %s? ", cmd, file); (void) fflush(stdout); - if (fgets(line, sizeof line, stdin) == NULL) + if (fgets(mline, sizeof mline, stdin) == NULL) return (0); - return (*line != 'n' && *line != 'N'); + return (*mline != 'n' && *mline != 'N'); } -fatal(msg) +void fatal(msg) char *msg; { @@ -1839,7 +1850,7 @@ fatal(msg) * Can't control multiple values being expanded * from the expression, we return only the first. */ -globulize(cpp) +static int globulize(cpp) char **cpp; { char **globbed; @@ -1866,23 +1877,23 @@ globulize(cpp) return (1); } -account(argc,argv) +void account(argc,argv) int argc; char **argv; { - char acct[50], *mygetpass(), *ap; + char macct[50], *ap; if (argc > 1) { ++argv; --argc; - (void) strncpy(acct,*argv,49); - acct[49] = '\0'; + (void) strncpy(macct,*argv,49); + macct[49] = '\0'; while (argc > 1) { --argc; ++argv; - (void) strncat(acct,*argv, 49-strlen(acct)); + (void) strncat(macct,*argv, 49-strlen(macct)); } - ap = acct; + ap = macct; } else { ap = mygetpass("Account:"); @@ -1892,7 +1903,7 @@ account(argc,argv) jmp_buf abortprox; -sigtype +static sigtype proxabort(sig) int sig; { @@ -1911,16 +1922,13 @@ proxabort(sig) longjmp(abortprox,1); } -doproxy(argc,argv) +void doproxy(argc,argv) int argc; char *argv[]; { - extern struct cmd cmdtab[]; - extern jmp_buf abortprox; register struct cmd *c; struct cmd *getcmd(); sig_t oldintr; - sigtype proxabort(); if (argc < 2 && !another(&argc, &argv, "command")) { printf("usage: %s command\n", argv[0]); @@ -1971,21 +1979,21 @@ doproxy(argc,argv) (void) signal(SIGINT, oldintr); } -setcase() +void setcase() { mcase = !mcase; printf("Case mapping %s.\n", onoff(mcase)); code = mcase; } -setcr() +void setcr() { crflag = !crflag; printf("Carriage Return stripping %s.\n", onoff(crflag)); code = crflag; } -setntrans(argc,argv) +void setntrans(argc,argv) int argc; char *argv[]; { @@ -2007,7 +2015,7 @@ setntrans(argc,argv) ntout[16] = '\0'; } -char * +static char * dotrans(name) char *name; { @@ -2035,7 +2043,7 @@ dotrans(name) return(new); } -setnmap(argc, argv) +void setnmap(argc, argv) int argc; char *argv[]; { @@ -2066,7 +2074,7 @@ setnmap(argc, argv) (void) strncpy(mapout, cp, MAXPATHLEN - 1); } -char * +static char * domap(name) char *name; { @@ -2236,14 +2244,14 @@ LOOP: return(new); } -setsunique() +void setsunique() { sunique = !sunique; printf("Store unique %s.\n", onoff(sunique)); code = sunique; } -setrunique() +void setrunique() { runique = !runique; printf("Receive unique %s.\n", onoff(runique)); @@ -2251,7 +2259,7 @@ setrunique() } /* change directory to perent directory */ -cdup() +void cdup() { if (command("CDUP") == ERROR && code == 500) { if (verbose) @@ -2261,7 +2269,7 @@ cdup() } /* restart transfer at specific point */ -restart(argc, argv) +void restart(argc, argv) int argc; char *argv[]; { @@ -2270,18 +2278,18 @@ restart(argc, argv) printf("restart: offset not specified\n"); else { restart_point = atol(argv[1]); - printf("restarting at %ld. %s\n", restart_point, + printf("restarting at %ld. %s\n", (long) restart_point, "execute get, put or append to initiate transfer"); } } /* show remote system type */ -syst() +void syst() { (void) command("SYST"); } -macdef(argc, argv) +void macdef(argc, argv) int argc; char *argv[]; { @@ -2344,7 +2352,7 @@ macdef(argc, argv) /* * get size of file on remote machine */ -sizecmd(argc, argv) +void sizecmd(argc, argv) int argc; char *argv[]; { @@ -2360,7 +2368,7 @@ sizecmd(argc, argv) /* * get last modification time of file on remote machine */ -modtime(argc, argv) +void modtime(argc, argv) int argc; char *argv[]; { @@ -2387,9 +2395,9 @@ modtime(argc, argv) } /* - * show status on reomte machine + * show status on remote machine */ -rmtstatus(argc, argv) +void rmtstatus(argc, argv) int argc; char *argv[]; { @@ -2399,7 +2407,7 @@ rmtstatus(argc, argv) /* * get file if modtime is more recent than current file */ -newer(argc, argv) +void newer(argc, argv) int argc; char *argv[]; { @@ -2414,7 +2422,7 @@ newer(argc, argv) */ /*VARARGS*/ -setpassive() +void setpassive() { passivemode = !passivemode; diff --git a/src/appl/gssftp/ftp/cmdtab.c b/src/appl/gssftp/ftp/cmdtab.c index de572996f..77511cb97 100644 --- a/src/appl/gssftp/ftp/cmdtab.c +++ b/src/appl/gssftp/ftp/cmdtab.c @@ -41,27 +41,6 @@ static char sccsid[] = "@(#)cmdtab.c 5.10 (Berkeley) 6/1/90"; /* * User FTP -- Command Tables. */ -int setascii(), setbell(), setbinary(), setdebug(), setform(); -int setglob(), sethash(), setmode(), setpeer(), setport(); -int setprompt(), setstruct(); -int settenex(), settrace(), settype(), setverbose(); -int setclevel(), setdlevel(), setclear(), setsafe(), ccc(); -#ifndef NOENCRYPTION -int setprivate(); -#endif -int disconnect(), restart(), reget(), syst(); -int cd(), lcd(), delete_file(), mdelete(), user(); -int ls(), mls(), get(), mget(), help(), append(), put(), mput(); -int quit(), renamefile(), status(); -int quote(), rmthelp(), shell(), site(); -int pwd(), makedir(), removedir(), setcr(); -int account(), doproxy(), reset(), setcase(), setntrans(), setnmap(); -int setsunique(), setrunique(), cdup(), macdef(), domacro(); -int sizecmd(), modtime(), newer(), rmtstatus(); -int do_chmod(), do_umask(), siteidle(); -#ifndef NO_PASSIVE_MODE -int setpassive(); -#endif char accounthelp[] = "send account command to remote server"; char appendhelp[] = "append to a file"; diff --git a/src/appl/gssftp/ftp/domacro.c b/src/appl/gssftp/ftp/domacro.c index ecfe9b4ad..f76690ffd 100644 --- a/src/appl/gssftp/ftp/domacro.c +++ b/src/appl/gssftp/ftp/domacro.c @@ -44,7 +44,7 @@ static char sccsid[] = "@(#)domacro.c 1.8 (Berkeley) 9/28/90"; #include #include -domacro(argc, argv) +void domacro(argc, argv) int argc; char *argv[]; { @@ -52,9 +52,8 @@ domacro(argc, argv) register char *cp1, *cp2; int count = 2, loopflg = 0; char line2[200]; - extern char **glob(), *globerr; + extern char **glob(); struct cmd *getcmd(), *c; - extern struct cmd cmdtab[]; if (argc < 2 && !another(&argc, &argv, "macro name")) { printf("Usage: %s macro_name.\n", argv[0]); @@ -106,7 +105,7 @@ TOP: loopflg = 1; cp1++; if (count < argc) { - if(cp2 + strlen(argv[j+1]) - line < sizeof(line)) + if(cp2 + strlen(argv[count]) - line < sizeof(line)) (void) strncpy(cp2, argv[count], sizeof(line) - 1 - (cp2 - line)); diff --git a/src/appl/gssftp/ftp/ftp.c b/src/appl/gssftp/ftp/ftp.c index a00850d95..d5e627cf9 100644 --- a/src/appl/gssftp/ftp/ftp.c +++ b/src/appl/gssftp/ftp/ftp.c @@ -64,6 +64,9 @@ static char sccsid[] = "@(#)ftp.c 5.38 (Berkeley) 4/22/91"; #ifdef HAVE_STDLIB_H #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif #include #include #include @@ -138,6 +141,18 @@ unsigned char *ucbuf; #define DEFINITIONS #include "ftp_var.h" +#include "secure.h" + +#ifdef GSSAPI +void user_gss_error PROTOTYPE((OM_uint32, OM_uint32, char *)); +#endif + +static void proxtrans PROTOTYPE((char *, char *, char *)); +static int initconn PROTOTYPE((void)); +static void ptransfer PROTOTYPE((char *, long, struct timeval *, struct timeval *)); +static void abort_remote PROTOTYPE((FILE *)); +static void tvsub PROTOTYPE((struct timeval *, struct timeval *, struct timeval *)); +static char *gunique PROTOTYPE((char *)); #define sig_t my_sig_t #define sigtype krb5_sigtype @@ -153,6 +168,7 @@ struct sockaddr_in myctladdr; uid_t getuid(); sig_t lostpeer(); off_t restart_point = 0; +jmp_buf ptabort; #define strerror(error) (sys_errlist[error]) #ifdef NEED_SYS_ERRLIST @@ -164,7 +180,7 @@ extern int connected; #define herror() printf("unknown host\n") FILE *cin, *cout; -FILE *dataconn(); +FILE *dataconn PROTOTYPE((char *)); char * hookup(host, port) @@ -280,19 +296,19 @@ bad: return ((char *)0); } -login(host) +int login(host) char *host; { char tmp[80]; - char *user, *pass, *acct, *getenv(), *getlogin(), *mygetpass(); + char *l_user, *pass, *l_acct, *getenv(), *getlogin(); int n, aflag = 0; - user = pass = acct = 0; - if (ruserpass(host, &user, &pass, &acct) < 0) { + l_user = pass = l_acct = 0; + if (ruserpass(host, &l_user, &pass, &l_acct) < 0) { code = -1; return(0); } - while (user == NULL) { + while (l_user == NULL) { char *myname; myname = getenv("LOGNAME"); @@ -313,11 +329,11 @@ login(host) (void) fgets(tmp, sizeof(tmp) - 1, stdin); tmp[strlen(tmp) - 1] = '\0'; if (*tmp == '\0') - user = myname; + l_user = myname; else - user = tmp; + l_user = tmp; } - n = command("USER %s", user); + n = command("USER %s", l_user); if (n == COMPLETE) { /* determine if we need to send a dummy password */ int oldverbose = verbose; @@ -348,15 +364,15 @@ login(host) } if (n == CONTINUE) { aflag++; - acct = mygetpass("Account:"); - n = command("ACCT %s", acct); + l_acct = mygetpass("Account:"); + n = command("ACCT %s", l_acct); } if (n != COMPLETE) { fprintf(stderr, "Login failed.\n"); return (0); } - if (!aflag && acct != NULL) - (void) command("ACCT %s", acct); + if (!aflag && l_acct != NULL) + (void) command("ACCT %s", l_acct); if (proxy) return(1); for (n = 0; n < macnum; ++n) { @@ -370,12 +386,10 @@ login(host) return (1); } -sigtype +static sigtype cmdabort(sig) int sig; { - extern jmp_buf ptabort; - printf("\n"); (void) fflush(stdout); abrtflag++; @@ -383,10 +397,10 @@ cmdabort(sig) longjmp(ptabort,1); } -secure_command(cmd) +static int secure_command(cmd) char *cmd; { - char in[FTP_BUFSIZ], out[FTP_BUFSIZ]; + unsigned char in[FTP_BUFSIZ], out[FTP_BUFSIZ]; int length; if (auth_type && clevel != PROT_C) { @@ -395,9 +409,9 @@ secure_command(cmd) if ((length = clevel == PROT_P ? krb_mk_priv((unsigned char *)cmd, (unsigned char *)out, strlen(cmd), schedule, - &cred.session, &myctladdr, &hisctladdr) + cred.session, &myctladdr, &hisctladdr) : krb_mk_safe((unsigned char *)cmd, (unsigned char *)out, - strlen(cmd), &cred.session, + strlen(cmd), cred.session, &myctladdr, &hisctladdr)) == -1) { fprintf(stderr, "krb_mk_%s failed for KERBEROS_V4\n", clevel == PROT_P ? "priv" : "safe"); @@ -432,14 +446,15 @@ secure_command(cmd) fprintf(stderr, "sealed (%s) %d bytes\n", clevel==PROT_P?"ENC":"MIC", out_buf.length); - memcpy(out, out_buf.value, - length=out_buf.length); + length=out_buf.length; + memcpy(out, out_buf.value, out_buf.length); gss_release_buffer(&min_stat, &out_buf); } } #endif /* GSSAPI */ /* Other auth types go here ... */ - if (kerror = radix_encode(out, in, &length, 0)) { + kerror = radix_encode(out, in, &length, 0); + if (kerror) { fprintf(stderr,"Couldn't base 64 encode command (%s)\n", radix_error(kerror)); return(0); @@ -455,10 +470,10 @@ secure_command(cmd) } #ifdef STDARG -command(char *fmt, ...) +int command(char *fmt, ...) #else /*VARARGS*/ -command(va_alist) +int command(va_alist) va_dcl #endif { @@ -469,7 +484,6 @@ va_dcl #endif int r; sig_t oldintr; - sigtype cmdabort(); abrtflag = 0; if (debug) { @@ -528,7 +542,7 @@ char *reply_parse, reply_buf[FTP_BUFSIZ], *reply_ptr; #include -getreply(expecteof) +int getreply(expecteof) int expecteof; { register int i, c, n; @@ -538,7 +552,6 @@ getreply(expecteof) sig_t oldintr; int pflag = 0; char *pt = pasv; - sigtype cmdabort(); char ibuf[FTP_BUFSIZ], obuf[FTP_BUFSIZ]; int safe = 0; #ifndef strpbrk @@ -603,7 +616,7 @@ getreply(expecteof) if (c != '\r' && (verbose > 0 || (verbose > -1 && n == '5' && dig > 4))) { if (proxflag && - (dig == 1 || dig == 5 && verbose == 0)) + (dig == 1 || (dig == 5 && verbose == 0))) printf("%s:",hostname); (void) putchar(c); } @@ -634,11 +647,12 @@ getreply(expecteof) if (auth_type && !ibuf[0] && n != '6') return(getreply(expecteof)); ibuf[0] = obuf[i] = '\0'; - if (code && n == '6') + if (code && n == '6') { if (code != 631 && code != 632 && code != 633) { printf("Unknown reply: %d %s\n", code, obuf); n = '5'; } else safe = (code == 631); + } if (obuf[0]) /* if there is a string to decode */ if (!auth_type) { printf("Cannot decode reply:\n%d %s\n", code, obuf); @@ -658,7 +672,10 @@ getreply(expecteof) #endif else { int len; - if (kerror = radix_encode(obuf, ibuf, &len, 1)) { + kerror = radix_encode((unsigned char *)obuf, + (unsigned char *)ibuf, + &len, 1); + if (kerror) { printf("Can't base 64 decode reply %d (%s)\n\"%s\"\n", code, radix_error(kerror), obuf); n = '5'; @@ -666,12 +683,16 @@ getreply(expecteof) #ifdef KRB5_KRB4_COMPAT else if (strcmp(auth_type, "KERBEROS_V4") == 0) if ((kerror = safe ? - krb_rd_safe((unsigned char *)ibuf, len, - &cred.session, - &hisctladdr, &myctladdr, &msg_data) - : krb_rd_priv((unsigned char *)ibuf, len, - schedule, &cred.session, - &hisctladdr, &myctladdr, &msg_data)) + krb_rd_safe((unsigned char *)ibuf, + (unsigned int) len, + cred.session, + &hisctladdr, + &myctladdr, &msg_data) + : krb_rd_priv((unsigned char *)ibuf, + (unsigned int) len, + schedule, cred.session, + &hisctladdr, &myctladdr, + &msg_data)) != KSUCCESS) { printf("%d reply %s! (krb_rd_%s: %s)\n", code, safe ? "modified" : "garbled", @@ -723,7 +744,7 @@ getreply(expecteof) /* Other auth types go here... */ } else - if (verbose > 0 || verbose > -1 && n == '5') { + if (verbose > 0 || (verbose > -1 && n == '5')) { (void) putchar(c); (void) fflush (stdout); } @@ -742,9 +763,11 @@ getreply(expecteof) (*oldintr)(SIGINT); if (reply_parse) { *reply_ptr = '\0'; - if (reply_ptr = strstr(reply_buf, reply_parse)) { + reply_ptr = strstr(reply_buf, reply_parse); + if (reply_ptr) { reply_parse = reply_ptr + strlen(reply_parse); - if (reply_ptr = strpbrk(reply_parse, " \r")) + reply_ptr = strpbrk(reply_parse, " \r"); + if (reply_ptr) *reply_ptr = '\0'; } else reply_parse = reply_ptr; } @@ -752,7 +775,7 @@ getreply(expecteof) } } -empty(mask, sec) +static int empty(mask, sec) fd_set *mask; int sec; { @@ -765,7 +788,7 @@ empty(mask, sec) jmp_buf sendabort; -sigtype +static sigtype abortsend(sig) int sig; { @@ -778,10 +801,10 @@ abortsend(sig) } #ifdef STDARG -secure_error(char *fmt, ...) +void secure_error(char *fmt, ...) #else /* VARARGS1 */ -secure_error(fmt, p1, p2, p3, p4, p5) +void secure_error(fmt, p1, p2, p3, p4, p5) char *fmt; #endif { @@ -799,7 +822,7 @@ secure_error(fmt, p1, p2, p3, p4, p5) #define HASHBYTES 1024 -sendrequest(cmd, local, remote, printnames) +void sendrequest(cmd, local, remote, printnames) char *cmd, *local, *remote; int printnames; { @@ -810,8 +833,8 @@ sendrequest(cmd, local, remote, printnames) int (*volatile closefunc)(), pclose(), fclose(); volatile sig_t oldintr, oldintp; volatile long bytes = 0, hashbytes = HASHBYTES; - char *volatile lmode, buf[FTP_BUFSIZ], *bufp; - sigtype abortsend(); + char *volatile lmode; + unsigned char buf[FTP_BUFSIZ], *bufp; if (verbose && printnames) { if (local && *local != '-') @@ -887,7 +910,7 @@ sendrequest(cmd, local, remote, printnames) return; } if (setjmp(sendabort)) - goto abort; + goto die; if (restart_point && (strcmp(cmd, "STOR") == 0 || strcmp(cmd, "APPE") == 0)) { @@ -929,7 +952,7 @@ sendrequest(cmd, local, remote, printnames) } dout = dataconn(lmode); if (dout == NULL) - goto abort; + goto die; (void) gettimeofday(&start, (struct timezone *)0); oldintp = signal(SIGPIPE, SIG_IGN); switch (curtype) { @@ -940,7 +963,8 @@ sendrequest(cmd, local, remote, printnames) while ((c = read(fileno(fin), buf, sizeof (buf))) > 0) { bytes += c; for (bufp = buf; c > 0; c -= d, bufp += d) - if ((d = secure_write(fileno(dout), bufp, c)) <= 0) + if ((d = secure_write(fileno(dout), bufp, + (unsigned int) c)) <= 0) break; if (hash) { while (bytes >= hashbytes) { @@ -985,7 +1009,7 @@ sendrequest(cmd, local, remote, printnames) break; bytes++; /* if (c == '\r') { */ - /* (void) putc('\0', dout); /* this violates rfc */ + /* (void) putc('\0', dout); this violates rfc */ /* bytes++; */ /* } */ } @@ -1017,7 +1041,7 @@ sendrequest(cmd, local, remote, printnames) if (bytes > 0) ptransfer("sent", bytes, &start, &stop); return; -abort: +die: (void) gettimeofday(&stop, (struct timezone *)0); (void) signal(SIGINT, oldintr); if (oldintp) @@ -1042,7 +1066,7 @@ abort: jmp_buf recvabort; -sigtype +static sigtype abortrecv(sig) int sig; { @@ -1054,23 +1078,21 @@ abortrecv(sig) longjmp(recvabort, 1); } -recvrequest(cmd, local, remote, lmode, printnames) +void recvrequest(cmd, local, remote, lmode, printnames) char *cmd, *volatile local, *remote, *lmode; { FILE *volatile fout, *volatile din = 0, *popen(); int (*volatile closefunc)(), pclose(), fclose(); volatile sig_t oldintr, oldintp; volatile int is_retr, tcrflag, bare_lfs = 0; - char *gunique(); - static int bufsize; + static unsigned int bufsize; static char *buf; - int blksize; + unsigned int blksize; volatile long bytes = 0, hashbytes = HASHBYTES; register int c, d; struct timeval start, stop; struct stat st; off_t lseek(); - sigtype abortrecv(); is_retr = strcmp(cmd, "RETR") == 0; if (is_retr && verbose && printnames) { @@ -1157,7 +1179,7 @@ recvrequest(cmd, local, remote, lmode, printnames) return; } if (setjmp(recvabort)) - goto abort; + goto die; if (is_retr && restart_point && command("REST %ld", (long) restart_point) != CONTINUE) return; @@ -1174,7 +1196,7 @@ recvrequest(cmd, local, remote, lmode, printnames) } din = dataconn("r"); if (din == NULL) - goto abort; + goto die; if (strcmp(local, "-") == 0) fout = stdout; else if (*local == '|') { @@ -1182,7 +1204,7 @@ recvrequest(cmd, local, remote, lmode, printnames) fout = popen(local + 1, "w"); if (fout == NULL) { perror(local+1); - goto abort; + goto die; } closefunc = pclose; } else { @@ -1190,7 +1212,7 @@ recvrequest(cmd, local, remote, lmode, printnames) if (fout == NULL) { fprintf(stderr, "local: %s: %s\n", local, strerror(errno)); - goto abort; + goto die; } closefunc = fclose; } @@ -1206,7 +1228,7 @@ recvrequest(cmd, local, remote, lmode, printnames) if (buf == NULL) { perror("malloc"); bufsize = 0; - goto abort; + goto die; } bufsize = blksize; } @@ -1225,7 +1247,8 @@ recvrequest(cmd, local, remote, lmode, printnames) } errno = d = 0; while ((c = secure_read(fileno(din), buf, bufsize)) > 0) { - if ((d = write(fileno(fout), buf, c)) != c) + d = write(fileno(fout), buf,(unsigned int) c); + if (d != c) break; bytes += c; if (hash) { @@ -1338,7 +1361,7 @@ break2: if (bytes > 0 && is_retr) ptransfer("received", bytes, &start, &stop); return; -abort: +die: /* abort using RFC959 recommended IP,SYNC sequence */ @@ -1371,7 +1394,7 @@ abort: * Need to start a listen on the data channel before we send the command, * otherwise the server's connect may fail. */ -initconn() +static int initconn() { register char *p, *a; int result, len, tmpno = 0; @@ -1519,7 +1542,7 @@ if (passivemode) return (fdopen(data, lmode)); } -ptransfer(direction, bytes, t0, t1) +static void ptransfer(direction, bytes, t0, t1) char *direction; long bytes; struct timeval *t0, *t1; @@ -1547,7 +1570,7 @@ ptransfer(direction, bytes, t0, t1) tsum->tv_sec++, tsum->tv_usec -= 1000000; } */ -tvsub(tdiff, t1, t0) +static void tvsub(tdiff, t1, t0) struct timeval *tdiff, *t1, *t0; { @@ -1557,19 +1580,16 @@ tvsub(tdiff, t1, t0) tdiff->tv_sec--, tdiff->tv_usec += 1000000; } -sigtype +static sigtype psabort(sig) int sig; { - extern int abrtflag; - abrtflag++; } -pswitch(flag) +void pswitch(flag) int flag; { - extern int proxy, abrtflag; sig_t oldintr; static struct comvars { int connect; @@ -1686,10 +1706,9 @@ pswitch(flag) } } -jmp_buf ptabort; int ptabflg; -sigtype +static sigtype abortpt(sig) int sig; { @@ -1701,16 +1720,15 @@ abortpt(sig) longjmp(ptabort, 1); } +static void proxtrans(cmd, local, remote) char *cmd, *local, *remote; { volatile sig_t oldintr; volatile int secndflag = 0; int prox_type, nfnd; - extern jmp_buf ptabort; char *volatile cmd2; fd_set mask; - sigtype abortpt(); if (strcmp(cmd, "RETR")) cmd2 = "RETR"; @@ -1742,7 +1760,7 @@ proxtrans(cmd, local, remote) return; } if (setjmp(ptabort)) - goto abort; + goto die; oldintr = signal(SIGINT, abortpt); if (command("%s %s", cmd, remote) != PRELIM) { (void) signal(SIGINT, oldintr); @@ -1753,7 +1771,7 @@ proxtrans(cmd, local, remote) pswitch(1); secndflag++; if (command("%s %s", cmd2, local) != PRELIM) - goto abort; + goto die; ptflag++; (void) getreply(0); pswitch(0); @@ -1763,7 +1781,7 @@ proxtrans(cmd, local, remote) ptflag = 0; printf("local: %s remote: %s\n", local, remote); return; -abort: +die: (void) signal(SIGINT, SIG_IGN); ptflag = 0; if (strcmp(cmd, "RETR") && !proxy) @@ -1822,7 +1840,7 @@ abort: (void) signal(SIGINT, oldintr); } -reset() +void reset() { fd_set mask; int nfnd = 1; @@ -1841,7 +1859,7 @@ reset() } } -char * +static char * gunique(local) char *local; { @@ -1903,13 +1921,12 @@ struct { int n_gss_trials = sizeof(gss_trials)/sizeof(gss_trials[0]); #endif /* GSSAPI */ -do_auth() +int do_auth() { - extern int setsafe(); int oldverbose = verbose; #ifdef KRB5_KRB4_COMPAT char *service, inst[INST_SZ]; - u_long cksum, checksum = (u_long) getpid(); + KRB4_32 cksum, checksum = getpid(); #endif /* KRB5_KRB4_COMPAT */ #if defined(KRB5_KRB4_COMPAT) || defined(GSSAPI) u_char out_buf[FTP_BUFSIZ]; @@ -1973,7 +1990,8 @@ do_auth() target_name, *gss_trials[trial].mech_type, GSS_C_MUTUAL_FLAG | GSS_C_REPLAY_FLAG | - (forward ? GSS_C_DELEG_FLAG : 0), + (forward ? GSS_C_DELEG_FLAG : + (unsigned) 0), 0, &chan, /* channel bindings */ token_ptr, @@ -2027,7 +2045,8 @@ do_auth() user_gss_error(maj_stat, min_stat, "no reply, huh?"); goto gss_complete_loop; } - } else if (kerror = radix_encode(reply_parse,out_buf,&i,1)) { + } else if ((kerror = radix_encode((unsigned char *)reply_parse, + out_buf,&i,1))) { fprintf(stderr, "Base 64 decoding failed: %s\n", radix_error(kerror)); } else { @@ -2073,6 +2092,7 @@ do_auth() if (realm[0] == '\0') strncpy(realm, (char *) krb_realmofhost(hostname), sizeof(realm) - 1); realm[sizeof(realm) - 1] = '\0'; + fprintf(stderr, "inst=%s, realm=%s, checksum %d\n", inst, realm, checksum); if ((kerror = krb_mk_req(&ticket, service = "ftp", inst, realm, checksum)) && (kerror != KDC_PR_UNKNOWN || @@ -2080,7 +2100,7 @@ do_auth() inst, realm, checksum)))) fprintf(stderr, "Kerberos V4 krb_mk_req failed: %s\n", krb_get_err_text(kerror)); - else if (kerror = krb_get_cred(service, inst, realm, &cred)) + else if ((kerror = krb_get_cred(service, inst, realm, &cred))) fprintf(stderr, "Kerberos V4 krb_get_cred failed: %s\n", krb_get_err_text(kerror)); else { @@ -2089,7 +2109,7 @@ do_auth() oldverbose = verbose; verbose = 0; i = ticket.length; - if (kerror = radix_encode(ticket.dat, out_buf, &i, 0)) + if ((kerror = radix_encode(ticket.dat, out_buf, &i, 0))) fprintf(stderr, "Base 64 encoding failed: %s\n", radix_error(kerror)); else if (command("ADAT %s", out_buf) != COMPLETE) @@ -2097,11 +2117,13 @@ do_auth() else if (!reply_parse) fprintf(stderr, "No authentication data received from server\n"); - else if (kerror = radix_encode(reply_parse, out_buf, &i, 1)) + else if ((kerror = radix_encode((unsigned char *)reply_parse, out_buf, &i, 1))) fprintf(stderr, "Base 64 decoding failed: %s\n", radix_error(kerror)); - else if (kerror = krb_rd_safe(out_buf, i, &cred.session, - &hisctladdr, &myctladdr, &msg_data)) + else if ((kerror = krb_rd_safe(out_buf, (unsigned )i, + cred.session, + &hisctladdr, &myctladdr, + &msg_data))) fprintf(stderr, "Kerberos V4 krb_rd_safe failed: %s\n", krb_get_err_text(kerror)); else { @@ -2129,6 +2151,7 @@ do_auth() return(0); } +void setpbsz(size) unsigned int size; { @@ -2156,7 +2179,7 @@ unsigned int size; verbose = oldverbose; } -abort_remote(din) +static void abort_remote(din) FILE *din; { char buf[FTP_BUFSIZ]; @@ -2196,15 +2219,15 @@ FILE *din; } (void) getreply(0); } + #ifdef GSSAPI -user_gss_error(maj_stat, min_stat, s) +void user_gss_error(maj_stat, min_stat, s) OM_uint32 maj_stat, min_stat; char *s; { /* a lot of work just to report the error */ - OM_uint32 gmaj_stat, gmin_stat; + OM_uint32 gmaj_stat, gmin_stat, msg_ctx; gss_buffer_desc msg; - int msg_ctx; msg_ctx = 0; while (!msg_ctx) { gmaj_stat = gss_display_status(&gmin_stat, maj_stat, @@ -2238,10 +2261,11 @@ char *s; fprintf(stderr, "GSSAPI error: %s\n", s); } -secure_gss_error(maj_stat, min_stat, s) +void secure_gss_error(maj_stat, min_stat, s) OM_uint32 maj_stat, min_stat; char *s; { - return user_gss_error(maj_stat, min_stat, s); + user_gss_error(maj_stat, min_stat, s); + return; } #endif /* GSSAPI */ diff --git a/src/appl/gssftp/ftp/ftp_var.h b/src/appl/gssftp/ftp/ftp_var.h index c2c03f39e..cc0080b1b 100644 --- a/src/appl/gssftp/ftp/ftp_var.h +++ b/src/appl/gssftp/ftp/ftp_var.h @@ -116,7 +116,7 @@ struct cmd { char c_bell; /* give bell when command completes */ char c_conn; /* must be connected to use command */ char c_proxy; /* proxy server may execute */ - int (*c_handler)(); /* function to call */ + void (*c_handler)(); /* function to call */ }; struct macel { @@ -134,10 +134,123 @@ extern char macbuf[4096]; #endif extern char *tail(); -extern char *remglob(); extern int errno; extern char *mktemp(); #if (defined(STDARG) || (defined(__STDC__) && ! defined(VARARGS))) || defined(HAVE_STDARG_H) -extern command(char *, ...); +extern int command(char *, ...); #endif + +#if (defined(__STDC__) || defined(__cplusplus) || defined(_MSDOS) || defined(_WIN32) || defined(KRB5_PROVIDE_PROTOTYPES)) && !defined(KRB5_NO_PROTOTYPES) +#define PROTOTYPE(x) x +#else +#define PROTOTYPE(x) () +#endif /* STDC or PROTOTYPES */ + +char *remglob PROTOTYPE((char **, int)); +int another PROTOTYPE((int *, char ***, char *)); +void makeargv PROTOTYPE((void)); +void setpeer PROTOTYPE((int, char **)); +void setclevel PROTOTYPE((int, char **)); +void setdlevel PROTOTYPE((int, char **)); +void ccc PROTOTYPE((void)); +void setclear PROTOTYPE((void)); +void setsafe PROTOTYPE((void)); +void setprivate PROTOTYPE((void)); +void settype PROTOTYPE((int, char **)); +void changetype PROTOTYPE((int, int)); +void setbinary PROTOTYPE((void)); +void setascii PROTOTYPE((void)); +void settenex PROTOTYPE((void)); +void setmode PROTOTYPE((int, char **)); +void setform PROTOTYPE((int, char **)); +void setstruct PROTOTYPE((int, char **)); +void siteidle PROTOTYPE((int, char **)); +void put PROTOTYPE((int, char **)); +void mput PROTOTYPE((int, char **)); +void reget PROTOTYPE((int, char **)); +void get PROTOTYPE((int, char **)); +void mget PROTOTYPE((int, char **)); +void status PROTOTYPE((int, char **)); +void setbell PROTOTYPE((void)); +void settrace PROTOTYPE((void)); +void sethash PROTOTYPE((void)); +void setverbose PROTOTYPE((void)); +void setport PROTOTYPE((void)); +void setprompt PROTOTYPE((void)); +void setglob PROTOTYPE((void)); +void setdebug PROTOTYPE((int, char **)); +void cd PROTOTYPE((int, char **)); +void lcd PROTOTYPE((int, char **)); +void delete_file PROTOTYPE((int, char **)); +void mdelete PROTOTYPE((int, char **)); +void renamefile PROTOTYPE((int, char **)); +void ls PROTOTYPE((int, char **)); +void mls PROTOTYPE((int, char **)); +void shell PROTOTYPE((int, char **)); +void user PROTOTYPE((int, char **)); +void pwd PROTOTYPE((void)); +void makedir PROTOTYPE((int, char **)); +void removedir PROTOTYPE((int, char **)); +void quote PROTOTYPE((int, char **)); +void site PROTOTYPE((int, char **)); +void do_chmod PROTOTYPE((int, char **)); +void do_umask PROTOTYPE((int, char **)); +void setidle PROTOTYPE((int, char **)); +void rmthelp PROTOTYPE((int, char **)); +void quit PROTOTYPE((void)); +void disconnect PROTOTYPE((void)); +void fatal PROTOTYPE((char *)); +void account PROTOTYPE((int, char **)); +void doproxy PROTOTYPE((int, char **)); +void setcase PROTOTYPE((void)); +void setcr PROTOTYPE((void)); +void setntrans PROTOTYPE((int, char **)); +void setnmap PROTOTYPE((int, char **)); +void setsunique PROTOTYPE((void)); +void setrunique PROTOTYPE((void)); +void cdup PROTOTYPE((void)); +void restart PROTOTYPE((int, char **)); +void syst PROTOTYPE((void)); +void macdef PROTOTYPE((int, char **)); +void sizecmd PROTOTYPE((int, char **)); +void modtime PROTOTYPE((int, char **)); +void rmtstatus PROTOTYPE((int, char **)); +void newer PROTOTYPE((int, char **)); +void setpassive PROTOTYPE((void)); + +/* ftp.c */ +void sendrequest PROTOTYPE((char *, char *, char *, int)); +void recvrequest PROTOTYPE((char *, char *, char *, char *, int)); +int login PROTOTYPE((char *)); +void setpbsz PROTOTYPE((unsigned int)); +void pswitch PROTOTYPE((int)); +int getreply PROTOTYPE((int)); +void reset PROTOTYPE((void)); +char *hookup PROTOTYPE((char *, int)); +int do_auth PROTOTYPE((void)); + +/* glob.c */ +void blkfree PROTOTYPE((char **)); + +/* domacro.c */ +void domacro PROTOTYPE((int, char **)); + + +/* main.c */ +void help PROTOTYPE((int, char **)); +struct cmd *getcmd PROTOTYPE((char *)); + + +/* ruserpass.c */ +int ruserpass PROTOTYPE((char *, char **, char **, char **)); + +/* radix.h */ +int radix_encode PROTOTYPE((unsigned char *, unsigned char *, int *, int)); +char *radix_error PROTOTYPE((int)); + +/* getpass.c */ +char *mygetpass PROTOTYPE((char *)); + +/* glob.c */ +char **ftpglob PROTOTYPE((char *)); diff --git a/src/appl/gssftp/ftp/getpass.c b/src/appl/gssftp/ftp/getpass.c index 9020373e9..622a32de9 100644 --- a/src/appl/gssftp/ftp/getpass.c +++ b/src/appl/gssftp/ftp/getpass.c @@ -8,6 +8,9 @@ static char sccsid[] = "@(#)getpass.c 1.1 90/04/28 SMI"; /* from UCB 5.4 3/7/86 */ #endif /* not lint */ +#ifdef HAVE_STDLIB_H +#include +#endif #include #include @@ -21,6 +24,8 @@ static struct termios ttyo, ttyb; static struct sgttyb ttyo, ttyb; #endif +#include "ftp_var.h" + static FILE *fi; #define sig_t my_sig_t @@ -41,7 +46,7 @@ mygetpass(prompt) char *prompt; { register char *p; - register c; + register int c; static char pbuf[50+1]; sigtype (*sig)(); diff --git a/src/appl/gssftp/ftp/glob.c b/src/appl/gssftp/ftp/glob.c index a5a6bf746..5ce2de62c 100644 --- a/src/appl/gssftp/ftp/glob.c +++ b/src/appl/gssftp/ftp/glob.c @@ -53,6 +53,8 @@ static char sccsid[] = "@(#)glob.c 5.9 (Berkeley) 2/25/91"; #include #endif +#include "ftp_var.h" + #ifdef ARG_MAX #undef NCARGS #define NCARGS ARG_MAX @@ -72,17 +74,24 @@ static char **gargv; /* Pointer to the (stack) arglist */ static int gargc; /* Number args in gargv */ static int gnleft; static short gflag; -static int tglob(); char **ftpglob(); char *globerr; char *home; extern int errno; -static char *strspl(), *strend(); -char **copyblk(); - -static void acollect(), addpath(), collect(), expand(), Gcat(); -static void ginit(), matchdir(), rscan(), sort(); -static int amatch(), execbrc(), match(); +static char *strspl PROTOTYPE((char *, char *)), *strend PROTOTYPE((char *)); +char **copyblk PROTOTYPE((char **)); + +static void acollect PROTOTYPE((char *)), addpath PROTOTYPE((int)), + collect PROTOTYPE((char *)), expand PROTOTYPE((char *)), + Gcat PROTOTYPE((char *, char *)); +static void ginit PROTOTYPE((char **)), matchdir PROTOTYPE((char *)), + rscan PROTOTYPE((char **, int (*f)())), sort PROTOTYPE((void)); +static int amatch PROTOTYPE((char *, char *)), + execbrc PROTOTYPE((char *, char *)), match PROTOTYPE((char *, char *)); +static int digit PROTOTYPE((int)), letter PROTOTYPE((int)), + any PROTOTYPE((int, char *)); +static int gethdir PROTOTYPE((char *)); +static int tglob PROTOTYPE((int )); static int globcnt; @@ -235,7 +244,9 @@ static void matchdir(pattern) char *pattern; { +#if 0 struct stat stb; +#endif register struct dirent *dp; DIR *dirp; @@ -267,7 +278,9 @@ matchdir(pattern) closedir(dirp); return; +#if 0 patherr1: +#endif closedir(dirp); patherr2: globerr = "Bad directory components"; @@ -393,7 +406,7 @@ amatch(s, p) case '[': ok = 0; lc = 077777; - while (cc = *p++) { + while ((cc = *p++)) { if (cc == ']') { if (ok) break; @@ -406,11 +419,12 @@ amatch(s, p) if (scc == (lc = cc)) ok++; } - if (cc == 0) + if (cc == 0) { if (ok) p--; else return 0; + } continue; case '*': @@ -449,12 +463,13 @@ slash: while (*s) addpath(*s++); addpath('/'); - if (stat(gpath, &stb) == 0 && isdir(stb)) + if (stat(gpath, &stb) == 0 && isdir(stb)) { if (*p == 0) { Gcat(gpath, ""); globcnt++; } else expand(p); + } gpathp = sgpathp; *gpathp = 0; return (0); @@ -462,7 +477,7 @@ slash: } } -static +static int Gmatch(s, p) register char *s, *p; { @@ -477,7 +492,7 @@ Gmatch(s, p) case '[': ok = 0; lc = 077777; - while (cc = *p++) { + while ((cc = *p++)) { if (cc == ']') { if (ok) break; @@ -490,11 +505,12 @@ Gmatch(s, p) if (scc == (lc = cc)) ok++; } - if (cc == 0) + if (cc == 0) { if (ok) p--; else return 0; + } continue; case '*': @@ -540,13 +556,13 @@ Gcat(s1, s2) static void addpath(c) - char c; + int c; { if (gpathp >= lastgpathp) globerr = "Pathname too long"; else { - *gpathp++ = c; + *gpathp++ = c & 0xff; *gpathp = 0; } } @@ -558,13 +574,14 @@ rscan(t, f) { register char *p, c; - while (p = *t++) { - if (f == tglob) + while ((p = *t++)) { + if (f == tglob) { if (*p == '~') gflag |= 2; else if (eq(p, "{") || eq(p, "{}")) continue; - while (c = *p++) + } + while ((c = *p++)) (*f)(c); } } @@ -581,9 +598,9 @@ scan(t, f) *p++ = (*f)(c); } */ -static +static int tglob(c) - register char c; + register int c; { if (any(c, globchars)) @@ -600,21 +617,23 @@ trim(c) } */ +static int letter(c) - register char c; + register int c; { - return (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z' || c == '_'); + return ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'); } +static int digit(c) - register char c; + register int c; { return (c >= '0' && c <= '9'); } -any(c, s) +static int any(c, s) register int c; register char *s; { @@ -624,7 +643,7 @@ any(c, s) return(1); return(0); } -blklen(av) +static int blklen(av) register char **av; { register int i = 0; @@ -634,19 +653,19 @@ blklen(av) return (i); } -char ** +static char ** blkcpy(oav, bv) char **oav; register char **bv; { register char **av = oav; - while (*av++ = *bv++) + while ((*av++ = *bv++)) continue; return (oav); } -blkfree(av0) +void blkfree(av0) char **av0; { register char **av = av0; @@ -697,13 +716,13 @@ strend(cp) * user whose home directory is sought is currently. * We write the home directory of the user back there. */ -gethdir(home) - char *home; +static int gethdir(mhome) + char *mhome; { - register struct passwd *pp = getpwnam(home); + register struct passwd *pp = getpwnam(mhome); - if (!pp || ((home + strlen(pp->pw_dir)) >= lastgpathp)) + if (!pp || ((mhome + strlen(pp->pw_dir)) >= lastgpathp)) return (1); - (void) strcpy(home, pp->pw_dir); + (void) strcpy(mhome, pp->pw_dir); return (0); } diff --git a/src/appl/gssftp/ftp/main.c b/src/appl/gssftp/ftp/main.c index 6c7e1e91b..6937e4036 100644 --- a/src/appl/gssftp/ftp/main.c +++ b/src/appl/gssftp/ftp/main.c @@ -44,6 +44,13 @@ static char sccsid[] = "@(#)main.c 5.18 (Berkeley) 3/1/91"; /* * FTP User Program -- Command Interface. */ +#ifdef HAVE_STDLIB_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + #include #include "ftp_var.h" #ifndef KRB5_KRB4_COMPAT @@ -70,7 +77,7 @@ static char sccsid[] = "@(#)main.c 5.18 (Berkeley) 3/1/91"; typedef sigtype (*sig_t)(); uid_t getuid(); -sigtype intr(), lostpeer(); +sigtype intr PROTOTYPE((int)), lostpeer PROTOTYPE((int)); extern char *home; char *getlogin(); #ifdef KRB5_KRB4_COMPAT @@ -79,6 +86,11 @@ struct servent staticsp; extern char realm[]; #endif /* KRB5_KRB4_COMPAT */ +static void cmdscanner PROTOTYPE((int)); +static char *slurpstring PROTOTYPE((void)); + + +int main(argc, argv) volatile int argc; char **volatile argv; @@ -282,13 +294,12 @@ tail(filename) /* * Command parser. */ +static void cmdscanner(top) int top; { register struct cmd *c; register int l; - struct cmd *getcmd(); - extern int help(); if (!top) (void) putchar('\n'); @@ -351,7 +362,7 @@ getcmd(name) longest = 0; nmatches = 0; found = 0; - for (c = cmdtab; p = c->c_name; c++) { + for (c = cmdtab; (p = c->c_name) != NULL; c++) { for (q = name; *q == *p++; q++) if (*q == 0) /* exact match? */ return (c); @@ -375,17 +386,16 @@ getcmd(name) int slrflag; -makeargv() +void makeargv() { char **argp; - char *slurpstring(); margc = 0; argp = margv; stringbase = line; /* scan from first of buffer */ argbase = argbuf; /* store from first of buffer */ slrflag = 0; - while (*argp++ = slurpstring()) + while ((*argp++ = slurpstring())) margc++; } @@ -394,7 +404,7 @@ makeargv() * implemented with FSM to * handle quoting and strings */ -char * +static char * slurpstring() { int got_one = 0; @@ -512,13 +522,13 @@ OUT: return((char *)0); } -#define HELPINDENT (sizeof ("directory")) +#define HELPINDENT ((int) sizeof("disconnect")) /* * Help command. * Call each command handler with argc == 0 and argv[0] == name. */ -help(argc, argv) +void help(argc, argv) int argc; char *argv[]; { diff --git a/src/appl/gssftp/ftp/radix.c b/src/appl/gssftp/ftp/radix.c index bba641f40..2d573b4be 100644 --- a/src/appl/gssftp/ftp/radix.c +++ b/src/appl/gssftp/ftp/radix.c @@ -2,12 +2,14 @@ #include #include +#include "ftp_var.h" + static char *radixN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static char pad = '='; -radix_encode(inbuf, outbuf, len, decode) +int radix_encode(inbuf, outbuf, len, decode) unsigned char inbuf[], outbuf[]; int *len, decode; { @@ -72,6 +74,7 @@ int *len, decode; char * radix_error(e) +int e; { switch (e) { case 0: return("Success"); diff --git a/src/appl/gssftp/ftp/ruserpass.c b/src/appl/gssftp/ftp/ruserpass.c index a3e676059..fdf0f0b67 100644 --- a/src/appl/gssftp/ftp/ruserpass.c +++ b/src/appl/gssftp/ftp/ruserpass.c @@ -41,6 +41,9 @@ static char sccsid[] = "@(#)ruserpass.c 5.3 (Berkeley) 3/1/91"; #ifdef HAVE_STDLIB_H #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif #include #include #include @@ -51,6 +54,7 @@ static char sccsid[] = "@(#)ruserpass.c 5.3 (Berkeley) 3/1/91"; #endif char *renvlook(), *getenv(); +static int token PROTOTYPE((void)); static FILE *cfile; #define DEFAULT 1 @@ -67,18 +71,18 @@ static struct toktab { char *tokstr; int tval; } toktab[]= { - "default", DEFAULT, - "login", LOGIN, - "password", PASSWD, - "passwd", PASSWD, - "account", ACCOUNT, - "machine", MACH, - "macdef", MACDEF, - 0, 0 + { "default", DEFAULT }, + { "login", LOGIN }, + { "password", PASSWD }, + { "passwd", PASSWD }, + { "account", ACCOUNT }, + { "machine", MACH }, + { "macdef", MACDEF }, + { NULL, 0 } }; -static +static int token() { char *cp; @@ -117,11 +121,12 @@ token() return (ID); } +int ruserpass(host, aname, apass, aacct) char *host, **aname, **apass, **aacct; { char *hdir, buf[FTP_BUFSIZ], *tmp; - char myname[MAXHOSTNAMELEN], *mydomain; + char myname[MAXHOSTNAMELEN + 1], *mydomain; int t, i, c, usedefault = 0; struct stat stb; @@ -161,12 +166,14 @@ next: goto match; if ((tmp = strchr(hostname, '.')) != NULL && strcasecmp(tmp, mydomain) == 0 && - strncasecmp(hostname, tokval, tmp-hostname) == 0 && + strncasecmp(hostname, tokval, + (unsigned) (tmp-hostname)) == 0 && tokval[tmp - hostname] == '\0') goto match; if ((tmp = strchr(host, '.')) != NULL && strcasecmp(tmp, mydomain) == 0 && - strncasecmp(host, tokval, tmp - host) == 0 && + strncasecmp(host, tokval, + (unsigned ) (tmp - host)) == 0 && tokval[tmp - host] == '\0') goto match; continue; @@ -175,7 +182,7 @@ next: while ((t = token()) && t != MACH && t != DEFAULT) switch(t) { case LOGIN: - if (token()) + if (token()) { if (*aname == 0) { *aname = malloc((unsigned) strlen(tokval) + 1); (void) strcpy(*aname, tokval); @@ -183,6 +190,7 @@ next: if (strcmp(*aname, tokval)) goto next; } + } break; case PASSWD: if (strcmp(*aname, "anonymous") && @@ -214,7 +222,9 @@ next: (void) fclose(cfile); return(0); } - while ((c=getc(cfile)) != EOF && c == ' ' || c == '\t'); + while ((c = getc(cfile)) != EOF) + if (c != ' ' && c != '\t') + break; if (c == EOF || c == '\n') { printf("Missing macdef name argument.\n"); goto bad; diff --git a/src/appl/gssftp/ftp/secure.c b/src/appl/gssftp/ftp/secure.c index e1f69b084..7599ccf20 100644 --- a/src/appl/gssftp/ftp/secure.c +++ b/src/appl/gssftp/ftp/secure.c @@ -4,6 +4,12 @@ * Only one security context, thus only work on one fd at a time! */ +#ifdef GSSAPI +#include +#include +extern gss_ctx_id_t gcontext; +#endif /* GSSAPI */ + #include /* stuff which is specific to client or server */ #ifdef KRB5_KRB4_COMPAT @@ -14,11 +20,6 @@ extern KTEXT_ST ticket; extern MSG_DAT msg_data; extern Key_schedule schedule; #endif /* KRB5_KRB4_COMPAT */ -#ifdef GSSAPI -#include -#include -extern gss_ctx_id_t gcontext; -#endif /* GSSAPI */ #include @@ -27,6 +28,9 @@ extern gss_ctx_id_t gcontext; #ifdef HAVE_STDLIB_H #include #endif +#ifdef HAVE_UNISTD_H +#include +#endif #include #include #include @@ -46,6 +50,7 @@ typedef unsigned long ftp_uint32; typedef long ftp_int32; #endif +static int secure_putbuf PROTOTYPE((int, unsigned char *, unsigned int)); extern struct sockaddr_in hisaddr; extern struct sockaddr_in myaddr; @@ -60,7 +65,7 @@ extern char *auth_type; #define MAX maxbuf extern unsigned int maxbuf; /* maximum output buffer size */ extern unsigned char *ucbuf; /* cleartext buffer */ -static unsigned int nout, bufp; /* number of chars in ucbuf, +static unsigned int nout; /* number of chars in ucbuf, * pointer into ucbuf */ #ifdef KRB5_KRB4_COMPAT @@ -142,15 +147,10 @@ looping_read(fd, buf, len) #endif -#if defined(STDARG) || (defined(__STDC__) && ! defined(VARARGS)) || defined(HAVE_STDARG_H) -extern secure_error(char *, ...); -#else -extern secure_error(); -#endif #define ERR -2 -static +static int secure_putbyte(fd, c) int fd; unsigned char c; @@ -171,17 +171,19 @@ return (c); * -1 on error (errno set) * -2 on security error */ -secure_flush(fd) +int secure_flush(fd) int fd; { int ret; if (dlevel == PROT_C) return(0); - if (nout) - if (ret = secure_putbuf(fd, ucbuf, nout)) + if (nout) { + ret = secure_putbuf(fd, ucbuf, nout); + if (ret) return(ret); - return(secure_putbuf(fd, "", nout = 0)); + } + return(secure_putbuf(fd, (unsigned char *) "", nout = 0)); } /* returns: @@ -189,8 +191,8 @@ int fd; * -1 on error * -2 on security error */ -secure_putc(c, stream) -char c; +int secure_putc(c, stream) +int c; FILE *stream; { if (dlevel == PROT_C) @@ -203,6 +205,7 @@ FILE *stream; * -1 on error (errno set) * -2 on security error */ +int secure_write(fd, buf, nbyte) int fd; unsigned char *buf; @@ -224,6 +227,7 @@ unsigned int nbyte; * -1 on error (errno set) * -2 on security error */ +static int secure_putbuf(fd, buf, nbyte) int fd; unsigned char *buf; @@ -296,17 +300,18 @@ unsigned int nbyte; } } - memcpy(outbuf, out_buf.value, length=out_buf.length); + length=out_buf.length; + memcpy(outbuf, out_buf.value, out_buf.length); gss_release_buffer(&min_stat, &out_buf); } #endif /* GSSAPI */ net_len = htonl((u_long) length); - if (looping_write(fd, &net_len, 4) == -1) return(-1); + if (looping_write(fd, (char *) &net_len, 4) == -1) return(-1); if (looping_write(fd, outbuf, length) != length) return(-1); return(0); } -static +static int secure_getbyte(fd) int fd; { @@ -316,7 +321,8 @@ int fd; ftp_uint32 length; if (nin == 0) { - if ((kerror = looping_read(fd, &length, sizeof(length))) + if ((kerror = looping_read(fd, (char *) &length, + sizeof(length))) != sizeof(length)) { secure_error("Couldn't read PROT buffer length: %d/%s", kerror, @@ -329,7 +335,7 @@ int fd; length, MAX); return(ERR); } - if ((kerror = looping_read(fd, ucbuf, length)) != length) { + if ((kerror = looping_read(fd, (char *) ucbuf, (int) length)) != length) { secure_error("Couldn't read %u byte PROT buffer: %s", length, kerror == -1 ? sys_errlist[errno] : "premature EOF"); @@ -338,11 +344,11 @@ int fd; /* Other auth types go here ... */ #ifdef KRB5_KRB4_COMPAT if (strcmp(auth_type, "KERBEROS_V4") == 0) { - if (kerror = dlevel == PROT_P ? + if ((kerror = dlevel == PROT_P ? krb_rd_priv(ucbuf, length, schedule, SESSION, &hisaddr, &myaddr, &msg_data) : krb_rd_safe(ucbuf, length, SESSION, - &hisaddr, &myaddr, &msg_data)) { + &hisaddr, &myaddr, &msg_data))) { secure_error("krb_rd_%s failed for KERBEROS_V4 (%s)", dlevel == PROT_P ? "priv" : "safe", krb_get_err_text(kerror)); @@ -388,7 +394,7 @@ int fd; * -1 on EOF * -2 on security error */ -secure_getc(stream) +int secure_getc(stream) FILE *stream; { if (dlevel == PROT_C) @@ -402,10 +408,10 @@ FILE *stream; * -1 on error (errno set), only for PROT_C * -2 on security error */ -secure_read(fd, buf, nbyte) +int secure_read(fd, buf, nbyte) int fd; char *buf; -int nbyte; +unsigned int nbyte; { static int c; int i; diff --git a/src/appl/gssftp/ftp/secure.h b/src/appl/gssftp/ftp/secure.h index 694bedaf5..641531daa 100644 --- a/src/appl/gssftp/ftp/secure.h +++ b/src/appl/gssftp/ftp/secure.h @@ -1,4 +1,25 @@ +#include + #define CRED_DECL extern CREDENTIALS cred; -#define SESSION &cred.session +#define SESSION cred.session #define myaddr myctladdr #define hisaddr hisdataaddr + +#if (defined(__STDC__) || defined(__cplusplus) || defined(_MSDOS) || defined(_WIN32) || defined(KRB5_PROVIDE_PROTOTYPES)) && !defined(KRB5_NO_PROTOTYPES) +#define PROTOTYPE(x) x +#else +#define PROTOTYPE(x) () +#endif /* STDC or PROTOTYPES */ + +int secure_flush PROTOTYPE((int)); +int secure_putc PROTOTYPE((int, FILE *)); +int secure_getc PROTOTYPE((FILE *)); +int secure_write PROTOTYPE((int, unsigned char *, unsigned int)); +int secure_read PROTOTYPE((int, char *, unsigned int)); +void secure_gss_error PROTOTYPE((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(); +#endif