Deleted Added
full compact
acl_from_text.c (91032) acl_from_text.c (91034)
1/*-
2 * Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999, 2000, 2001 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/lib/libc/posix1e/acl_from_text.c 91032 2002-02-21 23:12:25Z jedgar $
26 * $FreeBSD: head/lib/libc/posix1e/acl_from_text.c 91034 2002-02-21 23:17:19Z jedgar $
27 */
28/*
29 * acl_from_text: Convert a text-form ACL from a string to an acl_t.
30 */
31
32#include <sys/types.h>
33#include "namespace.h"
34#include <sys/acl.h>

--- 83 unchanged lines hidden (view full) ---

118 acl_t acl;
119 char *mybuf_p, *line, *cur, *notcomment, *comment, *entry;
120 char *tag, *qualifier, *permission;
121 int error;
122 uid_t id;
123
124 /* Local copy we can mess up. */
125 mybuf_p = strdup(buf_p);
27 */
28/*
29 * acl_from_text: Convert a text-form ACL from a string to an acl_t.
30 */
31
32#include <sys/types.h>
33#include "namespace.h"
34#include <sys/acl.h>

--- 83 unchanged lines hidden (view full) ---

118 acl_t acl;
119 char *mybuf_p, *line, *cur, *notcomment, *comment, *entry;
120 char *tag, *qualifier, *permission;
121 int error;
122 uid_t id;
123
124 /* Local copy we can mess up. */
125 mybuf_p = strdup(buf_p);
126 if (!mybuf_p)
126 if (mybuf_p == NULL)
127 return(NULL);
128
129 acl = acl_init(3);
127 return(NULL);
128
129 acl = acl_init(3);
130 if (!acl) {
130 if (acl == NULL) {
131 free(mybuf_p);
132 return(NULL);
133 }
134
135 /* Outer loop: delimit at \n boundaries. */
136 cur = mybuf_p;
137 while ((line = strsep(&cur, "\n"))) {
138 /* Now split the line on the first # to strip out comments. */
139 comment = line;
140 notcomment = strsep(&comment, "#");
141
142 /* Inner loop: delimit at ',' boundaries. */
143 while ((entry = strsep(&notcomment, ","))) {
144 /* Now split into three ':' delimited fields. */
145 tag = strsep(&entry, ":");
131 free(mybuf_p);
132 return(NULL);
133 }
134
135 /* Outer loop: delimit at \n boundaries. */
136 cur = mybuf_p;
137 while ((line = strsep(&cur, "\n"))) {
138 /* Now split the line on the first # to strip out comments. */
139 comment = line;
140 notcomment = strsep(&comment, "#");
141
142 /* Inner loop: delimit at ',' boundaries. */
143 while ((entry = strsep(&notcomment, ","))) {
144 /* Now split into three ':' delimited fields. */
145 tag = strsep(&entry, ":");
146 if (!tag) {
146 if (tag == NULL) {
147 errno = EINVAL;
148 goto error_label;
149 }
150 tag = string_skip_whitespace(tag);
151 if ((*tag == '\0') && (!entry)) {
152 /*
153 * Is an entirely comment line, skip to next
154 * comma.
155 */
156 continue;
157 }
158 string_trim_trailing_whitespace(tag);
159
160 qualifier = strsep(&entry, ":");
147 errno = EINVAL;
148 goto error_label;
149 }
150 tag = string_skip_whitespace(tag);
151 if ((*tag == '\0') && (!entry)) {
152 /*
153 * Is an entirely comment line, skip to next
154 * comma.
155 */
156 continue;
157 }
158 string_trim_trailing_whitespace(tag);
159
160 qualifier = strsep(&entry, ":");
161 if (!qualifier) {
161 if (qualifier == NULL) {
162 errno = EINVAL;
163 goto error_label;
164 }
165 qualifier = string_skip_whitespace(qualifier);
166 string_trim_trailing_whitespace(qualifier);
167
168 permission = strsep(&entry, ":");
162 errno = EINVAL;
163 goto error_label;
164 }
165 qualifier = string_skip_whitespace(qualifier);
166 string_trim_trailing_whitespace(qualifier);
167
168 permission = strsep(&entry, ":");
169 if ((!permission) || (entry)) {
169 if (permission == NULL || entry) {
170 errno = EINVAL;
171 goto error_label;
172 }
173 permission = string_skip_whitespace(permission);
174 string_trim_trailing_whitespace(permission);
175
176 t = acl_string_to_tag(tag, qualifier);
177 if (t == -1) {

--- 60 unchanged lines hidden ---
170 errno = EINVAL;
171 goto error_label;
172 }
173 permission = string_skip_whitespace(permission);
174 string_trim_trailing_whitespace(permission);
175
176 t = acl_string_to_tag(tag, qualifier);
177 if (t == -1) {

--- 60 unchanged lines hidden ---