strc{py,at}_truncate -> strlc{py,at}

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@6983 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1999-09-16 20:06:06 +00:00
parent 23d6d3764d
commit 8e441f1158
7 changed files with 22 additions and 20 deletions

View File

@@ -1,5 +1,7 @@
1999-09-16 Assar Westerlund <assar@sics.se> 1999-09-16 Assar Westerlund <assar@sics.se>
* strlcat.c (strlcat): call strlcpy
* strlcpy.c: update name and prototype * strlcpy.c: update name and prototype
* strlcat.c: update name and prototype * strlcat.c: update name and prototype

View File

@@ -59,13 +59,13 @@ print_arg (char *string, size_t len, int mdoc, int longp, struct getargs *arg)
if(mdoc){ if(mdoc){
if(longp) if(longp)
strcat_truncate(string, "= Ns", len); strlcat(string, "= Ns", len);
strcat_truncate(string, " Ar ", len); strlcat(string, " Ar ", len);
}else }else
if (longp) if (longp)
strcat_truncate (string, "=", len); strlcat (string, "=", len);
else else
strcat_truncate (string, " ", len); strlcat (string, " ", len);
if (arg->arg_help) if (arg->arg_help)
s = arg->arg_help; s = arg->arg_help;
@@ -76,7 +76,7 @@ print_arg (char *string, size_t len, int mdoc, int longp, struct getargs *arg)
else else
s = "<undefined>"; s = "<undefined>";
strcat_truncate(string, s, len); strlcat(string, s, len);
return 1 + strlen(s); return 1 + strlen(s);
} }
@@ -102,7 +102,7 @@ mandoc_template(struct getargs *args,
printf(".Dd %s\n", timestr); printf(".Dd %s\n", timestr);
p = strrchr(progname, '/'); p = strrchr(progname, '/');
if(p) p++; else p = progname; if(p) p++; else p = progname;
strcpy_truncate(cmd, p, sizeof(cmd)); strlcpy(cmd, p, sizeof(cmd));
strupr(cmd); strupr(cmd);
printf(".Dt %s SECTION\n", cmd); printf(".Dt %s SECTION\n", cmd);
@@ -222,19 +222,19 @@ arg_printusage (struct getargs *args,
if (args[i].long_name) { if (args[i].long_name) {
buf[0] = '\0'; buf[0] = '\0';
strcat_truncate(buf, "[--", sizeof(buf)); strlcat(buf, "[--", sizeof(buf));
len += 2; len += 2;
if(args[i].type == arg_negative_flag) { if(args[i].type == arg_negative_flag) {
strcat_truncate(buf, "no-", sizeof(buf)); strlcat(buf, "no-", sizeof(buf));
len += 3; len += 3;
} }
strcat_truncate(buf, args[i].long_name, sizeof(buf)); strlcat(buf, args[i].long_name, sizeof(buf));
len += strlen(args[i].long_name); len += strlen(args[i].long_name);
len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf), len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf),
0, 1, &args[i]); 0, 1, &args[i]);
strcat_truncate(buf, "]", sizeof(buf)); strlcat(buf, "]", sizeof(buf));
if(args[i].type == arg_strings) if(args[i].type == arg_strings)
strcat_truncate(buf, "...", sizeof(buf)); strlcat(buf, "...", sizeof(buf));
col = check_column(stderr, col, strlen(buf) + 1, columns); col = check_column(stderr, col, strlen(buf) + 1, columns);
col += fprintf(stderr, " %s", buf); col += fprintf(stderr, " %s", buf);
} }
@@ -243,9 +243,9 @@ arg_printusage (struct getargs *args,
len += 2; len += 2;
len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf), len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf),
0, 0, &args[i]); 0, 0, &args[i]);
strcat_truncate(buf, "]", sizeof(buf)); strlcat(buf, "]", sizeof(buf));
if(args[i].type == arg_strings) if(args[i].type == arg_strings)
strcat_truncate(buf, "...", sizeof(buf)); strlcat(buf, "...", sizeof(buf));
col = check_column(stderr, col, strlen(buf) + 1, columns); col = check_column(stderr, col, strlen(buf) + 1, columns);
col += fprintf(stderr, " %s", buf); col += fprintf(stderr, " %s", buf);
} }

View File

@@ -57,6 +57,6 @@ getcwd(char *path, size_t size)
char *ret; char *ret;
ret = getwd(xxx); ret = getwd(xxx);
if(ret) if(ret)
strcpy_truncate(path, xxx, size); strlcpy(path, xxx, size);
return ret; return ret;
} }

View File

@@ -65,11 +65,11 @@ gethostname(char *name, int namelen)
ret = uname (&utsname); ret = uname (&utsname);
if (ret < 0) if (ret < 0)
return ret; return ret;
strcpy_truncate (name, utsname.nodename, namelen); strlcpy (name, utsname.nodename, namelen);
return 0; return 0;
} }
#else #else
strcpy_truncate (name, "some.random.host", namelen); strlcpy (name, "some.random.host", namelen);
return 0; return 0;
#endif #endif
} }

View File

@@ -748,7 +748,7 @@ g_opendir(Char *str, glob_t *pglob)
char buf[MaxPathLen]; char buf[MaxPathLen];
if (!*str) if (!*str)
strcpy_truncate(buf, ".", sizeof(buf)); strlcpy(buf, ".", sizeof(buf));
else else
g_Ctoc(str, buf); g_Ctoc(str, buf);

View File

@@ -86,10 +86,10 @@ inaddr2str(struct in_addr addr, char *s, size_t len)
*p; *p;
++p) ++p)
if (memcmp (*p, &addr, sizeof(addr)) == 0) { if (memcmp (*p, &addr, sizeof(addr)) == 0) {
strcpy_truncate (s, h->h_name, len); strlcpy (s, h->h_name, len);
return; return;
} }
} }
strcpy_truncate (s, inet_ntoa (addr), len); strlcpy (s, inet_ntoa (addr), len);
return; return;
} }

View File

@@ -123,7 +123,7 @@ __ivaliduser(FILE *hostf, unsigned raddr, const char *luser,
sizeof(u_long), sizeof(u_long),
AF_INET)) == NULL) AF_INET)) == NULL)
return (-1); return (-1);
strcpy_truncate(hname, hp->h_name, sizeof(hname)); strlcpy(hname, hp->h_name, sizeof(hname));
while (fgets(buf, sizeof(buf), hostf)) { while (fgets(buf, sizeof(buf), hostf)) {
p = buf; p = buf;