merge strcpy_truncate branch

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5027 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1998-06-09 19:25:40 +00:00
parent e255dfc950
commit a5f54865d4
87 changed files with 689 additions and 499 deletions

View File

@@ -23,6 +23,8 @@ MKINSTALLDIRS = $(top_srcdir)/mkinstalldirs
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LN_S = @LN_S@
prefix = @prefix@
exec_prefix = @exec_prefix@
libdir = @libdir@
@@ -64,7 +66,7 @@ gssapi.c:
$(LN_S) $(srcdir)/../ftp/gssapi.c .
.c.o:
$(CC) -c -DFTP_SERVER -I$(srcdir) -I$(srcdir)/../common -I$(INCTOP) $(DEFS) $(CFLAGS) $(CPPFLAGS) $<
$(CC) -c -DFTP_SERVER -I. -I$(srcdir) -I$(srcdir)/../common -I$(INCTOP) $(DEFS) $(CFLAGS) $(CPPFLAGS) $<
install: all
$(MKINSTALLDIRS) $(DESTDIR)$(libexecdir)

View File

@@ -326,11 +326,11 @@ cmd
{
if(oobflag){
if (file_size != (off_t) -1)
reply(213, "Status: %ld of %ld bytes transferred",
reply(213, "Status: %lu of %lu bytes transferred",
(unsigned long)byte_count,
(unsigned long)file_size);
else
reply(213, "Status: %ld bytes transferred",
reply(213, "Status: %lu bytes transferred",
(unsigned long)byte_count);
}else
statcmd();
@@ -999,7 +999,7 @@ getline(char *s, int n)
cs = s;
/* tmpline may contain saved command from urgent mode interruption */
if(ftp_command){
strncpy(s, ftp_command, n);
strcpy_truncate(s, ftp_command, n);
if (debug)
syslog(LOG_DEBUG, "command: %s", s);
#ifdef XXX
@@ -1338,16 +1338,21 @@ help(struct tab *ctab, char *s)
columns = 1;
lines = (NCMDS + columns - 1) / columns;
for (i = 0; i < lines; i++) {
strcpy (buf, " ");
strcpy_truncate (buf, " ", sizeof(buf));
for (j = 0; j < columns; j++) {
c = ctab + j * lines + i;
snprintf (buf + strlen(buf), sizeof(buf) - strlen(buf),
"%s%c", c->name, c->implemented ? ' ' : '*');
snprintf (buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%s%c",
c->name,
c->implemented ? ' ' : '*');
if (c + lines >= &ctab[NCMDS])
break;
w = strlen(c->name) + 1;
while (w < width) {
strcat(buf, " ");
strcat_truncate (buf,
" ",
sizeof(buf));
w++;
}
}
@@ -1405,7 +1410,7 @@ sizecmd(char *filename)
}
fclose(fin);
reply(213, "%ld", (unsigned long)count);
reply(213, "%lu", (unsigned long)count);
break; }
default:
reply(504, "SIZE not implemented for Type %c.", "?AEIL"[type]);

View File

@@ -135,12 +135,12 @@ static void usage(void);
static char *
curdir(void)
{
static char path[MaxPathLen+1+1]; /* path + '/' + '\0' */
static char path[MaxPathLen+1]; /* path + '/' + '\0' */
if (getcwd(path, sizeof(path)-2) == NULL)
if (getcwd(path, sizeof(path)-1) == NULL)
return ("");
if (path[1] != '\0') /* special case for root dir. */
strcat(path, "/");
strcat_truncate(path, "/", sizeof(path));
/* For guest account, skip / since it's chrooted */
return (guest ? path+1 : path);
}
@@ -530,7 +530,7 @@ user(char *name)
}
}
if (logging)
strncpy(curname, name, sizeof(curname)-1);
strcpy_truncate(curname, name, sizeof(curname));
if(sec_complete) {
if(sec_userok(name) == 0)
do_login(232, name);
@@ -1092,14 +1092,14 @@ dataconn(char *name, off_t size, char *mode)
{
char sizebuf[32];
FILE *file;
int retry = 0, tos;
int retry = 0;
file_size = size;
byte_count = 0;
if (size >= 0)
snprintf(sizebuf, sizeof(sizebuf), " (%ld bytes)", (long)size);
else
strcpy(sizebuf, "");
*sizebuf = '\0';
if (pdata >= 0) {
struct sockaddr_in from;
int s, fromlen = sizeof(from);
@@ -1114,9 +1114,12 @@ dataconn(char *name, off_t size, char *mode)
close(pdata);
pdata = s;
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
tos = IPTOS_THROUGHPUT;
setsockopt(s, IPPROTO_IP, IP_TOS, (void *)&tos,
sizeof(int));
{
int tos = IPTOS_THROUGHPUT;
setsockopt(s, IPPROTO_IP, IP_TOS, (void *)&tos,
sizeof(tos));
}
#endif
reply(150, "Opening %s mode data connection for '%s'%s.",
type == TYPE_A ? "ASCII" : "BINARY", name, sizebuf);
@@ -1608,7 +1611,7 @@ removedir(char *name)
void
pwd(void)
{
char path[MaxPathLen + 1];
char path[MaxPathLen];
char *ret;
/* SunOS has a broken getcwd that does popen(pwd) (!!!), this

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 1996, 1997 Kungliga Tekniska H<>gskolan
* Copyright (c) 1995, 1996, 1997, 1998 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -66,7 +66,7 @@ store_ticket(KTEXT cip)
unsigned char kvno;
KTEXT_ST tkt;
int left = cip->length;
int len;
int kerror;
ptr = (char *) cip->dat;
@@ -76,29 +76,32 @@ store_ticket(KTEXT cip)
ptr += 8;
left -= 8;
if (strnlen(ptr, left) == left)
len = strnlen(ptr, left);
if (len == left)
return(INTK_BADPW);
/* extract server's name */
strcpy(sp.name, ptr);
ptr += strlen(sp.name) + 1;
left -= strlen(sp.name) + 1;
strcpy_truncate(sp.name, ptr, sizeof(sp.name));
ptr += len + 1;
left -= len + 1;
if (strnlen(ptr, left) == left)
len = strnlen(ptr, left);
if (len == left)
return(INTK_BADPW);
/* extract server's instance */
strcpy(sp.instance, ptr);
ptr += strlen(sp.instance) + 1;
left -= strlen(sp.instance) + 1;
strcpy_truncate(sp.instance, ptr, sizeof(sp.instance));
ptr += len + 1;
left -= len + 1;
if (strnlen(ptr, left) == left)
len = strnlen(ptr, left);
if (len == left)
return(INTK_BADPW);
/* extract server's realm */
strcpy(sp.realm,ptr);
ptr += strlen(sp.realm) + 1;
left -= strlen(sp.realm) + 1;
strcpy_truncate(sp.realm, ptr, sizeof(sp.realm));
ptr += len + 1;
left -= len + 1;
if(left < 3)
return INTK_BADPW;
@@ -297,12 +300,12 @@ klist(void)
" Issued", " Expires", " Principal (kvno)");
header = 0;
}
strcpy(buf1, short_date(c.issue_date));
strcpy_truncate(buf1, short_date(c.issue_date), sizeof(buf1));
c.issue_date = krb_life_to_time(c.issue_date, c.lifetime);
if (time(0) < (unsigned long) c.issue_date)
strcpy(buf2, short_date(c.issue_date));
strcpy_truncate(buf2, short_date(c.issue_date), sizeof(buf2));
else
strcpy(buf2, ">>> Expired <<< ");
strcpy_truncate(buf2, ">>> Expired <<< ", sizeof(buf2));
lreply(200, "%s %s %s (%d)", buf1, buf2,
krb_unparse_name_long(c.service, c.instance, c.realm), c.kvno);
}

View File

@@ -89,10 +89,10 @@ ftp_rooted(const char *path)
if(!home[0])
if((pwd = k_getpwnam("ftp")))
strcpy(home, pwd->pw_dir);
strcpy_truncate(home, pwd->pw_dir, sizeof(home));
snprintf(newpath, sizeof(newpath), "%s/%s", home, path);
if(access(newpath, X_OK))
strcpy(newpath, path);
strcpy_truncate(newpath, path, sizeof(newpath));
return newpath;
}