This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
*/
if (!gencache_init()) return False;
+ if (name_type > 255) {
+ return False; /* Don't store non-real name types. */
+ }
+
if ( DEBUGLEVEL >= 5 ) {
DEBUG(5, ("namecache_store: storing %d address%s for %s#%02x: ",
num_names, num_names == 1 ? "": "es", name, name_type));
}
key = namecache_key(name, name_type);
+ if (!key) {
+ return False;
+ }
+
expiry = time(NULL) + lp_name_cache_timeout();
/*
char *key, *value;
time_t timeout;
- *num_names = 0;
-
/* exit now if null pointers were passed as they're required further */
if (!ip_list || !num_names) return False;
if (!gencache_init())
return False;
+ if (name_type > 255) {
+ return False; /* Don't fetch non-real name types. */
+ }
+
+ *num_names = 0;
+
/*
* Use gencache interface - lookup the key
*/
key = namecache_key(name, name_type);
+ if (!key) {
+ return False;
+ }
if (!gencache_get(key, &value, &timeout)) {
DEBUG(5, ("no entry for %s#%02X found.\n", name, name_type));
- gencache_del(key);
SAFE_FREE(key);
- SAFE_FREE(value);
return False;
} else {
DEBUG(5, ("name %s#%02X found.\n", name, name_type));
return *num_names > 0; /* true only if some ip has been fetched */
}
+/**
+ * Remove a namecache entry. Needed for site support.
+ *
+ **/
+
+BOOL namecache_delete(const char *name, int name_type)
+{
+ BOOL ret;
+ char *key;
+
+ if (!gencache_init())
+ return False;
+
+ if (name_type > 255) {
+ return False; /* Don't fetch non-real name types. */
+ }
+
+ key = namecache_key(name, name_type);
+ if (!key) {
+ return False;
+ }
+ ret = gencache_del(key);
+ SAFE_FREE(key);
+ return ret;
+}
/**
* Delete single namecache entry. Look at the
if (!gencache_get(key, &value, &timeout)) {
DEBUG(5, ("namecache_status_fetch: no entry for %s found.\n", key));
- gencache_del(key);
SAFE_FREE(key);
- SAFE_FREE(value);
return False;
} else {
DEBUG(5, ("namecache_status_fetch: key %s -> %s\n", key, value ));