From: Bastian Blank <bastian@waldi.eu.org>
To: selinux@tycho.nsa.gov
Cc: Stephen Smalley <sds@epoch.ncsc.mil>
Subject: Re: [PATCH] libselinux-3
Date: Fri, 24 Oct 2003 21:08:12 +0200 [thread overview]
Message-ID: <20031024190812.GA10572@wavehammer.waldi.eu.org> (raw)
In-Reply-To: <20031023215434.GA24235@wavehammer.waldi.eu.org>
[-- Attachment #1: Type: text/plain, Size: 171 bytes --]
updated patch.
bastian
--
What kind of love is that? Not to be loved; never to have shown love.
-- Commissioner Nancy Hedford, "Metamorphosis",
stardate 3219.8
[-- Attachment #2: libselinux-3 --]
[-- Type: text/plain, Size: 7997 bytes --]
--- src/get_context_list.c (.../upstream/current/libselinux) (revision 62)
+++ src/get_context_list.c (.../trunk/libselinux) (revision 62)
@@ -36,13 +36,13 @@
an entry is found, and a 1 is returned otherwise.
*/
static int find_line (FILE *infile, security_context_t con, char *line,
- int length)
+ size_t length)
{
char *current_line;
char *ptr, *ptr2 = NULL;
int found = 0;
char *cc_str = 0;
- int cc_len = 0;
+ size_t cc_len = 0;
/* Skip the user field. */
cc_str = index(con, ':');
@@ -53,12 +53,12 @@
if (!cc_len)
return -1;
- current_line = (char *) malloc (length);
+ current_line = malloc (length);
if (!current_line)
return (-1);
while (!feof (infile)) {
if (!fgets(current_line, length, infile)) {
free(current_line);
return -1;
}
@@ -119,9 +119,9 @@
int pri_length)
{
char *ptr, *ptr2;
- int length;
+ size_t length;
security_context_t current_context;
- int current_context_len;
+ size_t current_context_len;
int count = 0;
ptr = instr;
@@ -205,7 +205,7 @@
{
FILE *config_file; /* The configuration file */
char *fname = 0; /* The name of the user's configuration file */
- int fname_len; /* The length of fname */
+ size_t fname_len; /* The length of fname */
struct passwd *pwd; /* The user's passwd structure */
int retval; /* The return value */
@@ -218,7 +218,7 @@
return -1;
}
fname_len = strlen (pwd->pw_dir) + 20;
- fname = (char *) malloc (fname_len);
+ fname = malloc (fname_len);
if (!fname)
{
return -1;
@@ -366,13 +366,13 @@
if (!ptr)
return -1;
plen = strlen(ptr);
- if (buf[plen-1] == '\n')
+ if (plen > 1 && buf[plen-1] == '\n')
buf[plen-1] = 0;
nlen = strlen(user)+1+plen+1;
*newcon = malloc(nlen);
rc = snprintf(*newcon, nlen, "%s:%s", user, ptr);
- if (rc < 0 || rc >= nlen) {
+ if (rc < 0 || (size_t) rc >= nlen) {
free(*newcon);
*newcon = 0;
return -1;
Index: src/fgetfilecon.c
===================================================================
--- src/fgetfilecon.c (.../upstream/current/libselinux) (revision 62)
+++ src/fgetfilecon.c (.../trunk/libselinux) (revision 62)
@@ -10,7 +10,7 @@
int fgetfilecon(int fd, security_context_t *context)
{
char *buf;
- ssize_t size;
+ size_t size;
ssize_t ret;
size = INITCONTEXTLEN+1;
@@ -23,11 +23,11 @@
if (ret < 0 && errno == ERANGE) {
char *newbuf;
- size = fgetxattr(fd, XATTR_NAME_SELINUX, NULL, 0);
- if (size < 0)
+ ret = fgetxattr(fd, XATTR_NAME_SELINUX, NULL, 0);
+ if (ret < 0)
goto out;
- size++;
+ size = ret + 1;
newbuf = realloc(buf, size);
if (!newbuf)
goto out;
Index: src/lgetfilecon.c
===================================================================
--- src/lgetfilecon.c (.../upstream/current/libselinux) (revision 62)
+++ src/lgetfilecon.c (.../trunk/libselinux) (revision 62)
@@ -10,7 +10,7 @@
int lgetfilecon(const char *path, security_context_t *context)
{
char *buf;
- ssize_t size;
+ size_t size;
ssize_t ret;
size = INITCONTEXTLEN+1;
@@ -23,11 +23,11 @@
if (ret < 0 && errno == ERANGE) {
char *newbuf;
- size = lgetxattr(path, XATTR_NAME_SELINUX, NULL, 0);
- if (size < 0)
+ ret = lgetxattr(path, XATTR_NAME_SELINUX, NULL, 0);
+ if (ret < 0)
goto out;
- size++;
+ size = ret + 1;
newbuf = realloc(buf, size);
if (!newbuf)
goto out;
Index: src/Makefile
===================================================================
--- src/Makefile (.../upstream/current/libselinux) (revision 62)
+++ src/Makefile (.../trunk/libselinux) (revision 62)
@@ -11,8 +11,9 @@
LIBSO=$(TARGET).$(LIBVERSION)
OBJS= $(patsubst %.c,%.o,$(wildcard *.c))
LOBJS= $(patsubst %.c,%.lo,$(wildcard *.c))
-CFLAGS = -Wall
-override CFLAGS += -I../include
+CFLAGS = -Wall -W -Werror -O2 -pipe
+override CFLAGS += -I../include
+LDFLAGS =
all: $(LIBA) $(LIBSO)
@@ -25,10 +26,10 @@
ln -sf $@ $(TARGET)
%.o: %.c
- $(CC) -o $@ -c $(CFLAGS) $<
+ $(CC) $(CFLAGS) -c -o $@ $<
%.lo: %.c
- $(CC) -o $@ -c -fPIC $(CFLAGS) $<
+ $(CC) $(CFLAGS) -fPIC -c -o $@ $<
install: all
test -d $(LIBDIR) || install -m 755 -d $(LIBDIR)
Index: src/fsetfilecon.c
===================================================================
Index: src/compute_av.c
===================================================================
--- src/compute_av.c (.../upstream/current/libselinux) (revision 62)
+++ src/compute_av.c (.../trunk/libselinux) (revision 62)
@@ -16,7 +16,7 @@
struct av_decision *avd)
{
char *buf;
- unsigned int len;
+ size_t len;
int fd, ret;
fd = open(SELINUXMNT "access", O_RDWR);
Index: src/helpers.c
===================================================================
--- src/helpers.c (.../upstream/current/libselinux) (revision 62)
+++ src/helpers.c (.../trunk/libselinux) (revision 62)
@@ -23,7 +23,7 @@
security_class_t string_to_security_class(const char *s)
{
- int val;
+ unsigned int val;
if (isdigit(s[0])) {
val = atoi(s);
@@ -45,7 +45,7 @@
{
char **common_pts = 0;
access_vector_t common_base = 0;
- int i, i2, perm;
+ unsigned int i, i2, perm;
if (av == 0) {
Index: src/lsetfilecon.c
===================================================================
Index: src/compute_user.c
===================================================================
--- src/compute_user.c (.../upstream/current/libselinux) (revision 62)
+++ src/compute_user.c (.../trunk/libselinux) (revision 62)
@@ -16,8 +16,8 @@
char **ary;
char *buf, *ptr;
size_t size;
- int fd, ret, i;
- unsigned int nel;
+ int fd, ret;
+ unsigned int i, nel;
fd = open(SELINUXMNT "user", O_RDWR);
if (fd < 0)
Index: src/getfilecon.c
===================================================================
--- src/getfilecon.c (.../upstream/current/libselinux) (revision 62)
+++ src/getfilecon.c (.../trunk/libselinux) (revision 62)
@@ -10,7 +10,7 @@
int getfilecon(const char *path, security_context_t *context)
{
char *buf;
- ssize_t size;
+ size_t size;
ssize_t ret;
size = INITCONTEXTLEN+1;
@@ -23,11 +23,11 @@
if (ret < 0 && errno == ERANGE) {
char *newbuf;
- size = getxattr(path, XATTR_NAME_SELINUX, NULL, 0);
- if (size < 0)
+ ret = getxattr(path, XATTR_NAME_SELINUX, NULL, 0);
+ if (ret < 0)
goto out;
- size++;
+ size = ret + 1;
newbuf = realloc(buf, size);
if (!newbuf)
goto out;
Index: src/get_default_type.c
===================================================================
--- src/get_default_type.c (.../upstream/current/libselinux) (revision 62)
+++ src/get_default_type.c (.../trunk/libselinux) (revision 62)
@@ -29,7 +29,7 @@
{
char buf[250];
char *ptr = "", *end, *t;
- int len;
+ size_t len;
int found = 0;
len = strlen(role);
Index: src/context.c
===================================================================
--- src/context.c (.../upstream/current/libselinux) (revision 62)
+++ src/context.c (.../trunk/libselinux) (revision 62)
@@ -93,14 +93,15 @@
context_str(context_t context)
{
context_private_t *n = context->ptr;
- int i, total;
+ int i;
+ size_t total = 0;
conditional_free(&n->current_str);
- for ( i = total = 0; i < 4; i++ ) {
+ for ( i = 0; i < 4; i++ ) {
if ( n->component[i] ) {
total += strlen(n->component[i])+1;
}
}
- n->current_str = (char*) malloc(total);
+ n->current_str = malloc(total);
if ( n->current_str != 0 ) {
strcpy(n->current_str,n->component[0]);
strcat(n->current_str,":");
next prev parent reply other threads:[~2003-10-24 19:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-10-23 21:54 [PATCH] libselinux-3 Bastian Blank
2003-10-24 19:08 ` Bastian Blank [this message]
2003-10-24 21:09 ` Stephen Smalley
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031024190812.GA10572@wavehammer.waldi.eu.org \
--to=bastian@waldi.eu.org \
--cc=sds@epoch.ncsc.mil \
--cc=selinux@tycho.nsa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.