Deleted Added
full compact
readdir.c (270002) readdir.c (282979)
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

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

26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
32#endif /* LIBC_SCCS and not lint */
33#include <sys/cdefs.h>
1/*
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. 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

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

26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#if defined(LIBC_SCCS) && !defined(lint)
31static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94";
32#endif /* LIBC_SCCS and not lint */
33#include <sys/cdefs.h>
34__FBSDID("$FreeBSD: stable/10/lib/libc/gen/readdir.c 270002 2014-08-14 20:20:21Z jhb $");
34__FBSDID("$FreeBSD: stable/10/lib/libc/gen/readdir.c 282979 2015-05-15 15:49:24Z julian $");
35
36#include "namespace.h"
37#include <sys/param.h>
38#include <dirent.h>
39#include <errno.h>
40#include <string.h>
41#include <pthread.h>
42#include "un-namespace.h"

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

49 * get next entry in a directory.
50 */
51struct dirent *
52_readdir_unlocked(dirp, skip)
53 DIR *dirp;
54 int skip;
55{
56 struct dirent *dp;
35
36#include "namespace.h"
37#include <sys/param.h>
38#include <dirent.h>
39#include <errno.h>
40#include <string.h>
41#include <pthread.h>
42#include "un-namespace.h"

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

49 * get next entry in a directory.
50 */
51struct dirent *
52_readdir_unlocked(dirp, skip)
53 DIR *dirp;
54 int skip;
55{
56 struct dirent *dp;
57 long initial_seek;
58 long initial_loc = 0;
57
58 for (;;) {
59 if (dirp->dd_loc >= dirp->dd_size) {
60 if (dirp->dd_flags & __DTF_READALL)
61 return (NULL);
59
60 for (;;) {
61 if (dirp->dd_loc >= dirp->dd_size) {
62 if (dirp->dd_flags & __DTF_READALL)
63 return (NULL);
64 initial_loc = dirp->dd_loc;
65 dirp->dd_flags &= ~__DTF_SKIPREAD;
62 dirp->dd_loc = 0;
63 }
64 if (dirp->dd_loc == 0 &&
65 !(dirp->dd_flags & (__DTF_READALL | __DTF_SKIPREAD))) {
66 dirp->dd_loc = 0;
67 }
68 if (dirp->dd_loc == 0 &&
69 !(dirp->dd_flags & (__DTF_READALL | __DTF_SKIPREAD))) {
70 initial_seek = dirp->dd_seek;
66 dirp->dd_size = _getdirentries(dirp->dd_fd,
67 dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
68 if (dirp->dd_size <= 0)
69 return (NULL);
71 dirp->dd_size = _getdirentries(dirp->dd_fd,
72 dirp->dd_buf, dirp->dd_len, &dirp->dd_seek);
73 if (dirp->dd_size <= 0)
74 return (NULL);
75 _fixtelldir(dirp, initial_seek, initial_loc);
70 }
71 dirp->dd_flags &= ~__DTF_SKIPREAD;
72 dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
73 if ((long)dp & 03L) /* bogus pointer check */
74 return (NULL);
75 if (dp->d_reclen <= 0 ||
76 dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc)
77 return (NULL);

--- 58 unchanged lines hidden ---
76 }
77 dirp->dd_flags &= ~__DTF_SKIPREAD;
78 dp = (struct dirent *)(dirp->dd_buf + dirp->dd_loc);
79 if ((long)dp & 03L) /* bogus pointer check */
80 return (NULL);
81 if (dp->d_reclen <= 0 ||
82 dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc)
83 return (NULL);

--- 58 unchanged lines hidden ---