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:
@@ -64,6 +64,11 @@ Thu Feb 12 03:30:08 1998 Assar Westerlund <assar@sics.se>
|
||||
|
||||
* parse_time.c (print_time_table): don't return a void value.
|
||||
|
||||
Tue Feb 3 11:06:24 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* getarg.c (mandoc_template): Change date format to full month
|
||||
name, and day of month without leading zero.
|
||||
|
||||
Thu Jan 22 21:23:23 1998 Johan Danielsson <joda@emma.pdc.kth.se>
|
||||
|
||||
* getarg.c: Fix long form of negative flags.
|
||||
|
||||
+3
-3
@@ -64,7 +64,7 @@ roken_vconcat (char *s, size_t len, va_list args)
|
||||
|
||||
if (n >= len)
|
||||
return -1;
|
||||
strncpy (s, a, n);
|
||||
memcpy (s, a, n);
|
||||
s += n;
|
||||
len -= n;
|
||||
}
|
||||
@@ -82,7 +82,6 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
|
||||
p = malloc(1);
|
||||
if(p == NULL)
|
||||
return 0;
|
||||
*p = 0;
|
||||
len = 1;
|
||||
while ((a = va_arg(args, const char*))) {
|
||||
size_t n = strlen (a);
|
||||
@@ -97,9 +96,10 @@ roken_vmconcat (char **s, size_t max_len, va_list args)
|
||||
return 0;
|
||||
}
|
||||
p = q;
|
||||
memcpy (p + len - 1, a, n);
|
||||
len += n;
|
||||
strcat(p, a);
|
||||
}
|
||||
p[len - 1] = '\0';
|
||||
*s = p;
|
||||
return len;
|
||||
}
|
||||
|
||||
+2
-3
@@ -97,12 +97,11 @@ mandoc_template(struct getargs *args,
|
||||
printf(".\\\" * use better macros for arguments (like .Pa for files)\n");
|
||||
printf(".\\\"\n");
|
||||
t = time(NULL);
|
||||
strftime(timestr, sizeof(timestr), "%b %d, %Y", localtime(&t));
|
||||
strftime(timestr, sizeof(timestr), "%B %e, %Y", localtime(&t));
|
||||
printf(".Dd %s\n", timestr);
|
||||
p = strrchr(__progname, '/');
|
||||
if(p) p++; else p = __progname;
|
||||
strncpy(cmd, p, sizeof(cmd));
|
||||
cmd[sizeof(cmd)-1] = '\0';
|
||||
strcpy_truncate(cmd, p, sizeof(cmd));
|
||||
strupr(cmd);
|
||||
|
||||
printf(".Dt %s SECTION\n", cmd);
|
||||
|
||||
+1
-1
@@ -57,6 +57,6 @@ getcwd(char *path, size_t size)
|
||||
char *ret;
|
||||
ret = getwd(xxx);
|
||||
if(ret)
|
||||
strncpy(path, xxx, size);
|
||||
strcpy_truncate(path, xxx, size);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -65,13 +65,11 @@ gethostname(char *name, int namelen)
|
||||
ret = uname (&utsname);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
strncpy (name, utsname.nodename, namelen);
|
||||
name[namelen-1] = '\0';
|
||||
strcpy_truncate (name, utsname.nodename, namelen);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
strncpy (name, "some.random.host", namelen);
|
||||
name[namelen-1] = '\0';
|
||||
strcpy_truncate (name, "some.random.host", namelen);
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
+1
-1
@@ -748,7 +748,7 @@ g_opendir(Char *str, glob_t *pglob)
|
||||
char buf[MaxPathLen];
|
||||
|
||||
if (!*str)
|
||||
strcpy(buf, ".");
|
||||
strcpy_truncate(buf, ".", sizeof(buf));
|
||||
else
|
||||
g_Ctoc(str, buf);
|
||||
|
||||
|
||||
@@ -84,12 +84,10 @@ inaddr2str(struct in_addr addr, char *s, size_t len)
|
||||
if(h)
|
||||
while ((p = *(h->h_addr_list)++))
|
||||
if (memcmp (p, &addr, sizeof(addr)) == 0) {
|
||||
strncpy (s, h->h_name, len);
|
||||
s[len - 1] = '\0';
|
||||
strcpy_truncate (s, h->h_name, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
strncpy (s, inet_ntoa (addr), len);
|
||||
s[len - 1] = '\0';
|
||||
strcpy_truncate (s, inet_ntoa (addr), len);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,8 +127,7 @@ __ivaliduser(FILE *hostf, unsigned raddr, const char *luser,
|
||||
sizeof(u_long),
|
||||
AF_INET)) == NULL)
|
||||
return (-1);
|
||||
strncpy(hname, hp->h_name, sizeof(hname));
|
||||
hname[sizeof(hname) - 1] = '\0';
|
||||
strcpy_truncate(hname, hp->h_name, sizeof(hname));
|
||||
|
||||
while (fgets(buf, sizeof(buf), hostf)) {
|
||||
p = buf;
|
||||
@@ -257,8 +256,7 @@ again:
|
||||
first = 0;
|
||||
if ((pwd = k_getpwnam((char*)luser)) == NULL)
|
||||
return (-1);
|
||||
strcpy(pbuf, pwd->pw_dir);
|
||||
strcat(pbuf, "/.rhosts");
|
||||
snprintf (pbuf, sizeof(pbuf), "%s/.rhosts", pwd->pw_dir);
|
||||
|
||||
/*
|
||||
* Change effective uid while opening .rhosts. If root and
|
||||
|
||||
@@ -193,6 +193,14 @@ char *strtok_r(char *s1, const char *s2, char **lasts);
|
||||
char * strupr(char *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCPY_TRUNCATE
|
||||
int strcpy_truncate (char *dst, const char *src, size_t dst_sz);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCAT_TRUNCATE
|
||||
int strcat_truncate (char *dst, const char *src, size_t dst_sz);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETDTABLESIZE
|
||||
int getdtablesize(void);
|
||||
#endif
|
||||
|
||||
@@ -70,6 +70,7 @@ struct state {
|
||||
/* XXX - methods */
|
||||
};
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
static int
|
||||
sn_reserve (struct state *state, size_t n)
|
||||
{
|
||||
@@ -86,6 +87,7 @@ sn_append_char (struct state *state, char c)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
as_reserve (struct state *state, size_t n)
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
#ifndef HAVE_STRCPY_TRUNCATE
|
||||
|
||||
int
|
||||
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
{
|
||||
@@ -59,3 +61,5 @@ strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
else
|
||||
return dst_sz;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
@@ -56,7 +56,7 @@ strerror(int eno)
|
||||
if(eno < 0 || eno >= sys_nerr)
|
||||
snprintf(emsg, sizeof(emsg), "Error %d occurred.", eno);
|
||||
else
|
||||
strcpy(emsg, sys_errlist[eno]);
|
||||
snprintf(emsg, sizeof(emsg), "%s", sys_errlist[eno]);
|
||||
|
||||
return emsg;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,8 @@
|
||||
|
||||
RCSID("$Id$");
|
||||
|
||||
#ifndef HAVE_STRCPY_TRUNCATE
|
||||
|
||||
int
|
||||
strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
{
|
||||
@@ -59,3 +61,5 @@ strcpy_truncate (char *dst, const char *src, size_t dst_sz)
|
||||
else
|
||||
return dst_sz;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user