Project

General

Profile

Bug #1826 » mod_webdav_POSIX_readdir-upd.patch

gstrauss, 2016-03-30 15:22

View differences:

src/mod_webdav.c
1348 1348
		prop_200 = buffer_init();
1349 1349
		prop_404 = buffer_init();
1350 1350

  
1351
		switch(depth) {
1352
		case 0:
1353
			/* Depth: 0 */
1351
		{
1352
			/* Depth: 0  or  Depth: 1 */
1354 1353
			webdav_get_props(srv, con, p, &(con->physical), req_props, prop_200, prop_404);
1355 1354

  
1356 1355
			buffer_append_string_len(b,CONST_STR_LEN("<D:response>\n"));
......
1387 1386
			}
1388 1387

  
1389 1388
			buffer_append_string_len(b,CONST_STR_LEN("</D:response>\n"));
1389
		}
1390

  
1391
		if (depth == 1) {
1390 1392

  
1391
			break;
1392
		case 1:
1393 1393
			if (NULL != (dir = opendir(con->physical.path->ptr))) {
1394 1394
				struct dirent *de;
1395 1395
				physical d;
......
1399 1399
				d.rel_path = buffer_init();
1400 1400

  
1401 1401
				while(NULL != (de = readdir(dir))) {
1402
					if (de->d_name[0] == '.' && de->d_name[1] == '.' && de->d_name[2] == '\0') {
1402
					if (de->d_name[0] == '.' && (de->d_name[1] == '\0' || (de->d_name[1] == '.' && de->d_name[2] == '\0'))) {
1403 1403
						continue;
1404
						/* ignore the parent dir */
1404
						/* ignore the parent and target dir */
1405 1405
					}
1406 1406

  
1407 1407
					buffer_copy_buffer(d.path, dst->path);
......
1410 1410
					buffer_copy_buffer(d.rel_path, dst->rel_path);
1411 1411
					buffer_append_slash(d.rel_path);
1412 1412

  
1413
					if (de->d_name[0] == '.' && de->d_name[1] == '\0') {
1414
						/* don't append the . */
1415
					} else {
1416
						buffer_append_string(d.path, de->d_name);
1417
						buffer_append_string(d.rel_path, de->d_name);
1418
					}
1413
					buffer_append_string(d.path, de->d_name);
1414
					buffer_append_string(d.rel_path, de->d_name);
1419 1415

  
1420 1416
					buffer_reset(prop_200);
1421 1417
					buffer_reset(prop_404);
......
1461 1457
				buffer_free(d.path);
1462 1458
				buffer_free(d.rel_path);
1463 1459
			}
1464
			break;
1460

  
1465 1461
		}
1466 1462

  
1467 1463
		if (req_props) {
(2-2/2)