summaryrefslogtreecommitdiff
path: root/usr.sbin/afs
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-20 14:59:30 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-04-20 14:59:30 +0000
commit06c62f7d247c4fe2707a0e8cd3da19c88e685364 (patch)
tree3752d1cca67827cda2498f209da34918cc4af6af /usr.sbin/afs
parent02dc875ac7c7880455dc06b53311aabac6624c2a (diff)
more afs string cleaning; pvalchev ok
Diffstat (limited to 'usr.sbin/afs')
-rw-r--r--usr.sbin/afs/src/appl/fs/fs.c9
-rw-r--r--usr.sbin/afs/src/ydr/main.c10
-rw-r--r--usr.sbin/afs/src/ydr/output.c27
3 files changed, 26 insertions, 20 deletions
diff --git a/usr.sbin/afs/src/appl/fs/fs.c b/usr.sbin/afs/src/appl/fs/fs.c
index 1366fd2c8be..ac6441e1541 100644
--- a/usr.sbin/afs/src/appl/fs/fs.c
+++ b/usr.sbin/afs/src/appl/fs/fs.c
@@ -1722,7 +1722,8 @@ afs_copyacl(char *fromdir, char *todir)
}
position=acl->neg;
for(i=0; i<acl->NumNegativeEntries; i++) {
- sprintf(tmpstr, "%s %d\n", position->name, position->RightsMask);
+ snprintf(tmpstr, sizeof tmpstr, "%s %d\n",
+ position->name, position->RightsMask);
strlcat(acltext, tmpstr, sizeof(acltext));
position=position->next;
}
@@ -1885,7 +1886,8 @@ afs_setacl(char *path, char *user, char *rights)
position && acl->NumPositiveEntries;
position = position->next) {
if (position->RightsMask) {
- sprintf(tmpstr, "%s %d\n", position->name, position->RightsMask);
+ snprintf(tmpstr, sizeof tmpstr, "%s %d\n",
+ position->name, position->RightsMask);
strlcat(acltext, tmpstr, sizeof(acltext));
} else
acl->NumPositiveEntries--;
@@ -1894,7 +1896,8 @@ afs_setacl(char *path, char *user, char *rights)
position && acl->NumNegativeEntries;
position = position->next) {
if (position->RightsMask) {
- sprintf(tmpstr, "%s %d\n", position->name, position->RightsMask);
+ snprintf(tmpstr, sizeof tmpstr, "%s %d\n",
+ position->name, position->RightsMask);
strlcat(acltext, tmpstr, sizeof(acltext));
} else
acl->NumNegativeEntries--;
diff --git a/usr.sbin/afs/src/ydr/main.c b/usr.sbin/afs/src/ydr/main.c
index a517637b121..a646e72eb8f 100644
--- a/usr.sbin/afs/src/ydr/main.c
+++ b/usr.sbin/afs/src/ydr/main.c
@@ -125,13 +125,13 @@ main (int argc, char **argv)
unlink (tmp_filename);
errx (1, "malloc: out of memory");
}
- strcpy (arg, cpp);
- strcat (arg, " ");
+ strlcpy (arg, cpp, arglen);
+ strlcat (arg, " ", arglen);
for (i = 1; i < argc - 1; ++i) {
- strcat (arg, argv[i]);
- strcat (arg, " ");
+ strlcat (arg, argv[i], arglen);
+ strlcat (arg, " ", arglen);
}
- strcat (arg, tmp_filename);
+ strlcat (arg, tmp_filename, arglen);
yyin = popen (arg, "r");
if (yyin == NULL) {
diff --git a/usr.sbin/afs/src/ydr/output.c b/usr.sbin/afs/src/ydr/output.c
index f560d2796b8..bcf1bec2195 100644
--- a/usr.sbin/afs/src/ydr/output.c
+++ b/usr.sbin/afs/src/ydr/output.c
@@ -151,10 +151,11 @@ print_type (char *name, Type *type, enum argtype argtype,
case TPOINTER :
{
char *tmp;
+ size_t len = strlen(name) + 2;
- tmp = (char *)emalloc (strlen(name) + 2);
+ tmp = (char *)emalloc (len);
*tmp = '*';
- strcpy (tmp+1, name);
+ strlcpy (tmp+1, name, len - 1);
print_type (tmp, type->subtype, argtype, decl, f);
free (tmp);
break;
@@ -168,11 +169,12 @@ print_type (char *name, Type *type, enum argtype argtype,
case TVARRAY :
{
char *s;
+ size_t len = strlen (name) + 6;
- s = (char *)emalloc (strlen (name) + 6);
+ s = (char *)emalloc (len);
*s = '*';
- strcpy (s + 1, name);
- strcat (s, "_len");
+ strlcpy (s + 1, name, len - 1);
+ strlcat (s, "_len", len);
fprintf (f, "struct {\n");
if (type->indextype)
@@ -784,8 +786,8 @@ encode_varray (char *name, Type *type, FILE *f, EncodeType encodetype,
char tmp[256];
Type lentype = {TULONG};
- strcpy (tmp, name);
- strcat (tmp, ".len");
+ strlcpy (tmp, name, sizeof tmp);
+ strlcat (tmp, ".len", sizeof tmp);
encode_type (tmp, type->indextype ? type->indextype : &lentype,
f, encodetype, side);
@@ -1051,9 +1053,9 @@ encode_entry (List *list, Listitem *item, void *arg)
char tmp[256];
struct context *context = (struct context *)arg;
- strcpy (tmp, context->name);
- strcat (tmp, ".");
- strcat (tmp, s->name);
+ strlcpy (tmp, context->name, sizeof tmp);
+ strlcat (tmp, ".", sizeof tmp);
+ strlcat (tmp, s->name, sizeof tmp);
if (s->type->type == TPOINTER
&& s->type->subtype->type == TUSERDEF
@@ -1483,9 +1485,10 @@ genencodein (List *list, Listitem *item, void *arg)
if (a->argtype == TIN || a->argtype == TINOUT) {
if (a->type->type == TPOINTER) {
- char *tmp = (char *)emalloc (strlen (a->name) + 4);
+ size_t len = strlen (a->name) + 4;
+ char *tmp = (char *)emalloc (len);
- sprintf (tmp, "(*%s)", a->name);
+ snprintf (tmp, len, "(*%s)", a->name);
encode_type (tmp, a->type->subtype, f, ENCODE_RX, CLIENT);
free (tmp);