Date: Wed, 27 Aug 2003 09:43:05 -0700 (PDT) From: Chris Vance <cvance@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 37030 for review Message-ID: <200308271643.h7RGh5qk003677@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=37030 Change 37030 by cvance@cvance_release on 2003/08/27 09:42:20 Sync context mangling code with the most recent SELinux distribution. Affected files ... .. //depot/projects/trustedbsd/sebsd/lib/libsebsd/context.c#2 edit Differences ... ==== //depot/projects/trustedbsd/sebsd/lib/libsebsd/context.c#2 (text+ko) ==== @@ -19,12 +19,12 @@ * 4 colon-separated components and no whitespace. */ context_t -context_new(char *str) +context_new(const char *str) { - int i,j,count,has_level; + int i,count; context_private_t *n = (context_private_t*) malloc(sizeof(context_private_t)); context_t result = (context_t) malloc(sizeof(context_s_t)); - char *p,*tok; + const char *p,*tok; if ( n == 0 || result == 0 ) { goto err; } n->current_str = n->component[0] = n->component[1] = n->component[2] = @@ -43,6 +43,8 @@ for ( i = 0, tok = str; *tok; i++ ) { for ( p = tok; *p && *p != ':'; p++ ) { /* empty */ } n->component[i] = (char*) malloc(p-tok+1); + if (n->component[i] == 0) + goto err; strncpy(n->component[i],tok,p-tok); n->component[i][p-tok] = '\0'; tok = *p ? p+1 : p; @@ -116,10 +118,10 @@ /* Returns nonzero iff failed */ -static int set_comp(context_private_t* n,int index,char *str) +static int set_comp(context_private_t* n,int index, const char *str) { char *t = (char*) malloc(strlen(str)+1); - char *p; + const char *p; if ( !t ) { return 1; } for ( p = str; *p; p++ ) { if ( *p == '\t' || *p == ' ' || *p == '\n' || *p == '\r' || @@ -135,7 +137,7 @@ } #define def_get(name,tag) \ -char * context_ ## name ## _get(context_t context) \ +const char * context_ ## name ## _get(context_t context) \ { \ context_private_t *n = context->ptr; \ return n->component[tag]; \ @@ -147,7 +149,7 @@ def_get(role,COMP_ROLE) #define def_set(name,tag) \ -int context_ ## name ## _set(context_t context, char* str) \ +int context_ ## name ## _set(context_t context, const char* str) \ { \ return set_comp(context->ptr,tag,str);\ } @@ -156,7 +158,7 @@ def_set(role,COMP_ROLE) def_set(user,COMP_USER) -int context_range_set(context_t context,char* str) +int context_range_set(context_t context,const char* str) { context_private_t *n = context->ptr; if ( ! n->component[COMP_RANGE] ) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308271643.h7RGh5qk003677>