#else
#include <netinet/in.h>
#endif
+#include <limits.h>
#include <string.h>
#include <rx/xdr.h>
#include <rx/rx.h>
#include <afs/ptclient.h>
#include <afs/ptuser.h>
#include "acl.h"
-
#ifdef AFS_PTHREAD_ENV
#include <assert.h>
#include <pthread.h>
if (sscanf(elist, "%d\n%d\n", &p, &n) != 2)
return -1;
- if (p + n > ACL_MAXENTRIES)
+ if (p < 0 || n < 0 || p > INT_MAX - n || p + n > ACL_MAXENTRIES)
return (-1);
acl_NewACL(p + n, acl);
(*acl)->total = p + n;
nextc++; /* now at the beginning of the entry list */
for (i = 0; i < (*acl)->positive; i++) {
int k;
- if (sscanf(nextc, "%s\t%d\n", lnames.namelist_val[i], &k) != 2) {
+ if (sscanf(nextc, "%63s\t%d\n", lnames.namelist_val[i], &k) != 2) {
free(lnames.namelist_val);
return (-1);
}
for (i = (*acl)->total - 1; i >= (*acl)->total - (*acl)->negative;
i--, j++) {
if (sscanf
- (nextc, "%s\t%d\n", lnames.namelist_val[j],
+ (nextc, "%63s\t%d\n", lnames.namelist_val[j],
&((*acl)->entries[j].rights)) != 2) {
free(lnames.namelist_val);
return (-1);
*/
is_dfs =
- sscanf(old_acl_string, "%d dfs:%d %s", &cur_acl.nplus, &cur_acl.dfs,
+ sscanf(old_acl_string, "%d dfs:%d %1024s", &cur_acl.nplus, &cur_acl.dfs,
cur_acl.cell);
ptr = strchr(old_acl_string, '\n');
ptr++;
*/
for (i = 0; i < (cur_acl.nplus + cur_acl.nminus); i++) {
- sscanf(ptr, "%s%d\n", cur_user, &cur_user_acl);
+ sscanf(ptr, "%63s%d\n", cur_user, &cur_user_acl);
/*
* Skip the entry for the user we are replacing/adding
*/
foo = line;
skip(&foo);
for (i = 0; ((lnames.namelist_len < PR_MAXLIST)
- && (sscanf(foo, "%s", lnames.namelist_val[i]) !=
+ && (sscanf(foo, "%63s", lnames.namelist_val[i]) !=
EOF)); i++) {
lnames.namelist_len++;
skip(&foo);
size = aid->idlist_len;
if (size == 0)
return 0;
- if (size < 0)
+ if (size < 0 || size > INT_MAX / PR_MAXNAMELEN)
return PRTOOMANY;
aname->namelist_val = (prname *) malloc(size * PR_MAXNAMELEN);
aname->namelist_len = 0;
/* grab the group name */
memset(gname, 0, PR_MAXNAMELEN);
memset(owner, 0, PR_MAXNAMELEN);
- sscanf(buf, "%s %d", gname, &id);
+ sscanf(buf, "%63s %d", gname, &id);
tmp = buf;
skip(&tmp);
skip(&tmp);
if (!fail) {
/* read members out of buf and add to the group */
memset(name, 0, PR_MAXNAMELEN);
- while (sscanf(tmp, "%s", name) != EOF) {
+ while (sscanf(tmp, "%63s", name) != EOF) {
if (strchr(name, ':') == NULL) {
/* then it's not a group */
code = pr_AddToGroup(name, gname);
memset(name, 0, PR_MAXNAMELEN);
tmp = buf;
tmp++;
- while (sscanf(tmp, "%s", name) != EOF) {
+ while (sscanf(tmp, "%63s", name) != EOF) {
if (strchr(name, ':') == NULL) {
/* then it's not a group */
code = pr_AddToGroup(name, gname);
tp->nplus = tp->nminus = 0;
tp->pluslist = tp->minuslist = 0;
tp->dfs = 0;
- sscanf(astr, "%d dfs:%d %s", &junk, &tp->dfs, tp->cell);
+ sscanf(astr, "%d dfs:%d %1024s", &junk, &tp->dfs, tp->cell);
return tp;
}
ta = (struct Acl *)malloc(sizeof(struct Acl));
assert(ta);
ta->dfs = 0;
- sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
+ sscanf(astr, "%d dfs:%d %1024s", &ta->nplus, &ta->dfs, ta->cell);
astr = SkipLine(astr);
sscanf(astr, "%d", &ta->nminus);
astr = SkipLine(astr);
last = 0;
first = 0;
for (i = 0; i < nplus; i++) {
- sscanf(astr, "%100s %d", tname, &trights);
+ sscanf(astr, "%99s %d", tname, &trights);
astr = SkipLine(astr);
tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
assert(tl);
last = 0;
first = 0;
for (i = 0; i < nminus; i++) {
- sscanf(astr, "%100s %d", tname, &trights);
+ sscanf(astr, "%99s %d", tname, &trights);
astr = SkipLine(astr);
tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
assert(tl);