| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | #include <unistd.h> |
| 22 | #include <string.h> |
| 23 | |
| 24 | #include <hurd/netfs.h> |
| 25 | |
| 26 | #include "ftpfs.h" |
| 27 | |
| 28 | |
| 29 | static void |
| 30 | node_unlink (struct node *node, struct ftpfs *fs) |
| 31 | { |
| 32 | struct netnode *nn = node->nn; |
| 7 | | Access to field 'nn' results in a dereference of a null pointer (loaded from variable 'node') |
|
| 33 | if (nn->ncache_next) |
| 34 | nn->ncache_next->nn->ncache_prev = nn->ncache_prev; |
| 35 | if (nn->ncache_prev) |
| 36 | nn->ncache_prev->nn->ncache_next = nn->ncache_next; |
| 37 | if (fs->node_cache_mru == node) |
| 38 | fs->node_cache_mru = nn->ncache_next; |
| 39 | if (fs->node_cache_lru == node) |
| 40 | fs->node_cache_lru = nn->ncache_prev; |
| 41 | nn->ncache_next = 0; |
| 42 | nn->ncache_prev = 0; |
| 43 | fs->node_cache_len--; |
| 44 | } |
| 45 | |
| 46 | |
| 47 | |
| 48 | void |
| 49 | ftpfs_cache_node (struct node *node) |
| 50 | { |
| 51 | struct netnode *nn = node->nn; |
| 52 | struct ftpfs *fs = nn->fs; |
| 53 | |
| 54 | pthread_mutex_lock (&fs->node_cache_lock); |
| 55 | |
| 56 | if (fs->params.node_cache_max > 0 || fs->node_cache_len > 0) |
| 57 | { |
| 58 | if (fs->node_cache_mru != node) |
| |
| 59 | { |
| 60 | if (nn->ncache_next || nn->ncache_prev) |
| 61 | |
| 62 | node_unlink (node, fs); |
| 63 | else |
| 64 | |
| 65 | netfs_nref (node); |
| 66 | |
| 67 | nn->ncache_next = fs->node_cache_mru; |
| 68 | nn->ncache_prev = 0; |
| 69 | if (fs->node_cache_mru) |
| 70 | fs->node_cache_mru->nn->ncache_prev = node; |
| 71 | if (! fs->node_cache_lru) |
| 72 | fs->node_cache_lru = node; |
| 73 | fs->node_cache_mru = node; |
| 74 | fs->node_cache_len++; |
| 75 | } |
| 76 | |
| 77 | |
| 78 | while (fs->node_cache_len > fs->params.node_cache_max) |
| 2 | | Loop condition is true. Entering loop body | |
|
| 3 | | Loop condition is true. Entering loop body | |
|
| 79 | { |
| 80 | struct node *lru = fs->node_cache_lru; |
| 4 | | Variable 'lru' initialized to a null pointer value | |
|
| 81 | node_unlink (lru, fs); |
| 5 | | Passing null pointer value via 1st parameter 'node' | |
|
| |
| 82 | netfs_nrele (lru); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | pthread_mutex_unlock (&fs->node_cache_lock); |
| 87 | } |