View | Details | Raw Unified | Return to bug 155746
Collapse All | Expand All

(-)a/attr/libattr/libattr.c (-13 / +13 lines)
Lines 268-274 attr_list(const char *path, char *buffer Link Here
268
	  attrlist_cursor_t *cursor)
268
	  attrlist_cursor_t *cursor)
269
{
269
{
270
	const char *l;
270
	const char *l;
271
	int length, count = 0;
271
	int length, vlength, count = 0;
272
	char lbuf[MAXLISTLEN];
272
	char lbuf[MAXLISTLEN];
273
	char name[MAXNAMELEN+16];
273
	char name[MAXNAMELEN+16];
274
	unsigned int start_offset, end_offset;
274
	unsigned int start_offset, end_offset;
Lines 293-306 attr_list(const char *path, char *buffer Link Here
293
		if (api_unconvert(name, l, flags))
293
		if (api_unconvert(name, l, flags))
294
			continue;
294
			continue;
295
		if (flags & ATTR_DONTFOLLOW)
295
		if (flags & ATTR_DONTFOLLOW)
296
			length = lgetxattr(path, l, NULL, 0);
296
			vlength = lgetxattr(path, l, NULL, 0);
297
		else
297
		else
298
			length =  getxattr(path, l, NULL, 0);
298
			vlength =  getxattr(path, l, NULL, 0);
299
		if (length < 0 && (errno == ENOATTR || errno == ENOTSUP))
299
		if (vlength < 0 && (errno == ENOATTR || errno == ENOTSUP))
300
			continue;
300
			continue;
301
		if (count++ < cursor->opaque[0])
301
		if (count++ < cursor->opaque[0])
302
			continue;
302
			continue;
303
		if (attr_list_pack(name, length, buffer, buffersize,
303
		if (attr_list_pack(name, vlength, buffer, buffersize,
304
				   &start_offset, &end_offset)) {
304
				   &start_offset, &end_offset)) {
305
			cursor->opaque[0] = count;
305
			cursor->opaque[0] = count;
306
			break;
306
			break;
Lines 314-320 attr_listf(int fd, char *buffer, const i Link Here
314
	   attrlist_cursor_t *cursor)
314
	   attrlist_cursor_t *cursor)
315
{
315
{
316
	const char *l;
316
	const char *l;
317
	int c, count = 0;
317
	int length, vlength, count = 0;
318
	char lbuf[MAXLISTLEN];
318
	char lbuf[MAXLISTLEN];
319
	char name[MAXNAMELEN+16];
319
	char name[MAXNAMELEN+16];
320
	unsigned int start_offset, end_offset;
320
	unsigned int start_offset, end_offset;
Lines 325-346 attr_listf(int fd, char *buffer, const i Link Here
325
	}
325
	}
326
	bzero(buffer, sizeof(attrlist_t));
326
	bzero(buffer, sizeof(attrlist_t));
327
327
328
	c = flistxattr(fd, lbuf, sizeof(lbuf));
328
	length = flistxattr(fd, lbuf, sizeof(lbuf));
329
	if (c < 0)
329
	if (length < 0)
330
		return c;
330
		return length;
331
331
332
	start_offset = sizeof(attrlist_t);
332
	start_offset = sizeof(attrlist_t);
333
	end_offset = buffersize & ~(8-1);	/* 8 byte align */
333
	end_offset = buffersize & ~(8-1);	/* 8 byte align */
334
334
335
	for (l = lbuf; l != lbuf + c; l = strchr(l, '\0') + 1) {
335
	for (l = lbuf; l != lbuf + length; l = strchr(l, '\0') + 1) {
336
		if (api_unconvert(name, l, flags))
336
		if (api_unconvert(name, l, flags))
337
			continue;
337
			continue;
338
		c = fgetxattr(fd, l, NULL, 0);
338
		vlength = fgetxattr(fd, l, NULL, 0);
339
		if (c < 0 && (errno == ENOATTR || errno == ENOTSUP))
339
		if (vlength < 0 && (errno == ENOATTR || errno == ENOTSUP))
340
			continue;
340
			continue;
341
		if (count++ < cursor->opaque[0])
341
		if (count++ < cursor->opaque[0])
342
			continue;
342
			continue;
343
		if (attr_list_pack(name, c, buffer, buffersize,
343
		if (attr_list_pack(name, vlength, buffer, buffersize,
344
				   &start_offset, &end_offset)) {
344
				   &start_offset, &end_offset)) {
345
			cursor->opaque[0] = count;
345
			cursor->opaque[0] = count;
346
			break;
346
			break;

Return to bug 155746