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
+5
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
+2 -4
View File
@@ -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
View File
@@ -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);
+2 -4
View File
@@ -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;
}
+2 -4
View File
@@ -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
+8
View File
@@ -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
+2
View File
@@ -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)
+4
View File
@@ -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
+2 -2
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.
*
@@ -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;
}
+4
View File
@@ -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