dns_rdataset_init(&rdataset);
if (usekeyset || filename != NULL) {
- if (argc < isc_commandline_index + 1 && filename != NULL) {
+ if (argc < isc_commandline_index + 1) {
/* using zone name as the zone file name */
namestr = filename;
} else {
if (usekeyset) {
result = loadkeyset(dir, &rdataset);
} else {
+ INSIST(filename != NULL);
result = loadset(filename, &rdataset);
}
if (stack != NULL)
isc_mem_put(mctx, stack, stackcount * sizeof(*stack));
+ INSIST(dscpcount == addrcount);
INSIST(keycount == addrcount);
INSIST(keycount == dscpcount);
char buf[1024+32];
const dns_master_style_t *style;
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
- if (dctx->mdctx != NULL)
+ }
+ if (dctx->mdctx != NULL) {
dns_dumpctx_detach(&dctx->mdctx);
+ }
if (dctx->view == NULL) {
dctx->view = ISC_LIST_HEAD(dctx->viewlist);
- if (dctx->view == NULL)
+ if (dctx->view == NULL) {
goto done;
+ }
INSIST(dctx->zone == NULL);
- } else
+ } else {
goto resume;
+ }
nextview:
fprintf(dctx->fp, ";\n; Start view %s\n;\n", dctx->view->view->name);
resume:
{
style = &dns_master_style_cache;
/* start cache dump */
- if (dctx->view->view->cachedb != NULL)
+ if (dctx->view->view->cachedb != NULL) {
dns_db_attach(dctx->view->view->cachedb, &dctx->cache);
+ }
if (dctx->cache != NULL) {
fprintf(dctx->fp,
";\n; Cache dump of view '%s' (cache %s)\n;\n",
dctx->task,
dumpdone, dctx,
&dctx->mdctx);
- if (result == DNS_R_CONTINUE)
+ if (result == DNS_R_CONTINUE) {
return;
- if (result == ISC_R_NOTIMPLEMENTED)
+ }
+ if (result == ISC_R_NOTIMPLEMENTED) {
fprintf(dctx->fp, "; %s\n",
dns_result_totext(result));
- else if (result != ISC_R_SUCCESS)
+ } else if (result != ISC_R_SUCCESS) {
goto cleanup;
+ }
}
}
if ((dctx->dumpadb || dctx->dumpbad || dctx->dumpfail) &&
- dctx->cache == NULL && dctx->view->view->cachedb != NULL)
+ dctx->cache == NULL && dctx->view->view->cachedb != NULL) {
dns_db_attach(dctx->view->view->cachedb, &dctx->cache);
+ }
if (dctx->cache != NULL) {
- if (dctx->dumpadb)
+ if (dctx->dumpadb) {
dns_adb_dump(dctx->view->view->adb, dctx->fp);
- if (dctx->dumpbad)
+ }
+ if (dctx->dumpbad) {
dns_resolver_printbadcache(dctx->view->view->resolver,
dctx->fp);
- if (dctx->dumpfail)
+ }
+ if (dctx->dumpfail) {
dns_badcache_print(dctx->view->view->failcache,
"SERVFAIL cache", dctx->fp);
+ }
dns_db_detach(&dctx->cache);
}
if (dctx->dumpzones) {
style = &dns_master_style_full;
nextzone:
- if (dctx->version != NULL)
+ if (dctx->version != NULL) {
dns_db_closeversion(dctx->db, &dctx->version,
false);
- if (dctx->db != NULL)
+ }
+ if (dctx->db != NULL) {
dns_db_detach(&dctx->db);
- if (dctx->zone == NULL)
+ }
+ if (dctx->zone == NULL) {
dctx->zone = ISC_LIST_HEAD(dctx->view->zonelist);
- else
+ } else {
dctx->zone = ISC_LIST_NEXT(dctx->zone, link);
+ }
if (dctx->zone != NULL) {
/* start zone dump */
dns_zone_name(dctx->zone->zone, buf, sizeof(buf));
dctx->task,
dumpdone, dctx,
&dctx->mdctx);
- if (result == DNS_R_CONTINUE)
+ if (result == DNS_R_CONTINUE) {
return;
+ }
if (result == ISC_R_NOTIMPLEMENTED) {
fprintf(dctx->fp, "; %s\n",
dns_result_totext(result));
POST(result);
goto nextzone;
}
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
goto cleanup;
+ }
}
}
- if (dctx->view != NULL)
+ if (dctx->view != NULL) {
dctx->view = ISC_LIST_NEXT(dctx->view, link);
- if (dctx->view != NULL)
- goto nextview;
+ if (dctx->view != NULL) {
+ goto nextview;
+ }
+ }
done:
fprintf(dctx->fp, "; Dump complete\n");
result = isc_stdio_flush(dctx->fp);
- if (result == ISC_R_SUCCESS)
+ if (result == ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_INFO,
"dumpdb complete");
+ }
cleanup:
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_ERROR,
"dumpdb failed: %s", dns_result_totext(result));
+ }
dumpcontext_destroy(dctx);
}
/* Look for the optional class name. */
classtxt = next_token(lex, text);
if (classtxt != NULL) {
+ isc_textregion_t r;
+
/* Look for the optional view name. */
viewtxt = next_token(lex, text);
- }
-
- if (classtxt != NULL) {
- isc_textregion_t r;
+ /*
+ * If 'classtext' is not a valid class then it us a view name.
+ */
r.base = classtxt;
r.length = strlen(classtxt);
result = dns_rdataclass_fromtext(&rdclass, &r);
static isc_mem_t *mctx = NULL;
+ISC_PLATFORM_NORETURN_PRE static inline void
+fatal(const char *message) ISC_PLATFORM_NORETURN_POST;
+
static inline void
fatal(const char *message) {
fprintf(stderr, "%s\n", message);
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
UNUSED(id);
result = gettimeofday(&tv, NULL);
- if (result)
- return (result);
- tp->tv_sec = tv.tv_sec;
- tp->tv_nsec = (long) tv.tv_usec * 1000;
+ if (result == 0) {
+ tp->tv_sec = tv.tv_sec;
+ tp->tv_nsec = (long) tv.tv_usec * 1000;
+ }
return (result);
}
#endif
fprintf(stderr,
"C_DestroyObject: Error = 0x%.8lX\n",
rv);
- errflg = 1;
+ error = 1;
}
}
static isc_result_t
parse_netprefix(isc_sockaddr_t **sap, const char *value) {
- isc_result_t result = ISC_R_SUCCESS;
isc_sockaddr_t *sa = NULL;
struct in_addr in4;
struct in6_addr in6;
slash = strchr(buf, '/');
if (slash != NULL) {
+ isc_result_t result;
*slash = '\0';
result = isc_parse_uint32(&netmask, slash + 1, 10);
if (result != ISC_R_SUCCESS) {
ui.usri1_flags = UF_PASSWD_CANT_CHANGE | UF_DONT_EXPIRE_PASSWD |
UF_SCRIPT;
ui.usri1_script_path = NULL;
+
/*
* Call the NetUserAdd function, specifying level 1.
*/
nStatus = NetUserAdd(NULL, dwLevel, (LPBYTE)&ui, &dwError);
-
- if (nStatus != NERR_Success)
+ if (nStatus != NERR_Success) {
return (FALSE);
+ }
retstat = AddPrivilegeToAcccount(name, SE_SERVICE_LOGON_PRIV);
+ if (retstat != RTN_OK) {
+ return (FALSE);
+ }
+
return (TRUE);
}
/*
* Open the policy on the target machine.
*/
- if ((Status = OpenPolicy(NULL, POLICY_ALL_ACCESS, &PolicyHandle))
- != STATUS_SUCCESS)
+ Status = OpenPolicy(NULL, POLICY_ALL_ACCESS, &PolicyHandle);
+ if (Status != STATUS_SUCCESS) {
return (RTN_ERROR);
+ }
/*
* Let's see if the account exists. Return if not
}
err = LsaNtStatusToWinError(SetPrivilegeOnAccount(PolicyHandle,
- pSid, PrivilegeName, TRUE));
+ pSid, PrivilegeName, TRUE));
LsaClose(PolicyHandle);
- if (err == ERROR_SUCCESS)
+ if (err == ERROR_SUCCESS) {
return (RTN_OK);
- else
+ } else {
return (err);
+ }
}
void
NTSTATUS Status;
LSA_UNICODE_STRING *UserRights;
ULONG CountOfRights;
- unsigned int retlen = 0;
DWORD i, j;
int found;
return (Status);
for (i = 0; i < CountOfRights; i++) {
+ unsigned int retlen;
found = -1;
retlen = UserRights[i].Length/sizeof(wchar_t);
for (j = 0; j < *PrivCount; j++) {
IDS_UNINSTALL_MESSAGE "Unregister Messages..."
IDS_ERR_OPEN_SCM "Could not open Service Control Manager\n(%s)"
IDS_ERR_OPEN_SERVICE "Could not open BIND Service\n(%s)"
+ IDS_ERR_START_SERVICE "Could not start BIND Service\n(%s)"
IDS_ERR_STOP_SERVICE "Could not stop BIND Service\n(%s)"
IDS_ERR_NONCRIT_FILE "An error occurred while copying non-critical file %s\n(%s)\nDo you wish to continue?"
IDS_ERR_COPY_FILE "An error occurred while copying file %s\n(%s)\nInstallation will be terminated"
char winsys[MAX_PATH];
//{{AFX_DATA_INIT(CBINDInstallDlg)
+ /* cppcheck-suppress useInitializationList */
m_targetDir = _T("");
m_version = _T("");
m_toolsOnly = FALSE;
SERVICE_ERROR_NORMAL, pathBuffer, NULL, NULL, NULL,
StartName, m_accountPassword, BIND_DISPLAY_NAME)
!= TRUE) {
- DWORD err = GetLastError();
MsgBox(IDS_ERR_UPDATE_SERVICE, GetErrMessage());
}
}
}
BOOL rc = ControlService(hBINDSvc, SERVICE_CONTROL_STOP, &svcStatus);
+ if (!rc) {
+ MsgBox(IDS_ERR_STOP_SERVICE, GetErrMessage());
+ }
}
/*
}
SC_HANDLE hBINDSvc = OpenService(hSCManager, BIND_SERVICE_NAME,
- SERVICE_ALL_ACCESS);
+ SERVICE_ALL_ACCESS);
if (!hBINDSvc) {
MsgBox(IDS_ERR_OPEN_SERVICE, GetErrMessage());
}
BOOL rc = StartService(hBINDSvc, 0, NULL);
+ if (!rc) {
+ MsgBox(IDS_ERR_START_SERVICE, GetErrMessage());
+ }
}
/*
* Check to see if the BIND service is running or not
*/
-BOOL CBINDInstallDlg::CheckBINDService() {
+BOOL
+CBINDInstallDlg::CheckBINDService() {
SERVICE_STATUS svcStatus;
SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (hSCManager) {
SC_HANDLE hBINDSvc = OpenService(hSCManager, BIND_SERVICE_NAME,
- SERVICE_ALL_ACCESS);
+ SERVICE_ALL_ACCESS);
if (hBINDSvc) {
BOOL rc = ControlService(hBINDSvc,
- SERVICE_CONTROL_INTERROGATE, &svcStatus);
- if (!rc)
+ SERVICE_CONTROL_INTERROGATE,
+ &svcStatus);
+ if (!rc) {
+ /* cppcheck-suppress unreadVariable */
DWORD err = GetLastError();
+ }
- return (svcStatus.dwCurrentState == SERVICE_RUNNING);
+ return (rc &&
+ svcStatus.dwCurrentState == SERVICE_RUNNING);
}
}
return (FALSE);
return;
}
- hr = SHGetPathFromIDList(itemList, commonPath);
- pMalloc->Free(itemList);
-
- if (create) {
- ProgramGroupCreate(commonPath);
+ if (SHGetPathFromIDList(itemList, commonPath)) {
+ if (create) {
+ ProgramGroupCreate(commonPath);
+ } else {
+ ProgramGroupRemove(commonPath);
+ }
} else {
- ProgramGroupRemove(commonPath);
+ MessageBox("SHGetPathFromIDList failed");
}
+ pMalloc->Free(itemList);
}
CString CBINDInstallDlg::DestDir(int destination) {
//{{AFX_DATA_INIT(CDirBrowse)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
+ /* cppcheck-suppress useInitializationList */
m_selectedDir = initialDir;
}
// And finally the version info is ours
m_fixedInfo = (VS_FIXEDFILEINFO *)viBlob;
- UINT blobLen = 0;
-
// If we got here, all is good
}
m_isValid = TRUE;
#define IDC_ACCOUNT_PASSWORD 1031
#define IDC_ACCOUNT_PASSWORD_CONFIRM 1032
#define IDC_TOOLS_ONLY 1033
+#define IDS_ERR_START_SERVICE 1034
// Next default values for new objects
//
static void
nullmsg(dns_rdatacallbacks_t *cb, const char *fmt, ...) {
- va_list ap;
UNUSED(cb);
UNUSED(fmt);
- UNUSED(ap);
}
-int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+int
+LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
char totext[1024];
dns_compress_t cctx;
dns_decompress_t dctx;
}
static isc_result_t
-publish(dns_rdata_t *rdata, dns_diff_t *diff, dns_name_t *origin,
+addrdata(dns_rdata_t *rdata, dns_diff_t *diff, const dns_name_t *origin,
dns_ttl_t ttl, isc_mem_t *mctx)
{
isc_result_t result;
}
static isc_result_t
-delrdata(dns_rdata_t *rdata, dns_diff_t *diff, dns_name_t *origin,
+delrdata(dns_rdata_t *rdata, dns_diff_t *diff, const dns_name_t *origin,
dns_ttl_t ttl, isc_mem_t *mctx)
{
isc_result_t result;
void (*report)(const char *, ...))
{
isc_result_t result;
- dns_difftuple_t *tuple = NULL;
unsigned char buf[DST_KEY_MAXSIZE];
char keystr[DST_KEY_FORMATSIZE];
dns_rdata_t dnskey = DNS_RDATA_INIT;
}
/* publish key */
- RETERR(dns_difftuple_create(mctx, DNS_DIFFOP_ADD, origin, ttl,
- &dnskey, &tuple));
- dns_diff_appendminimal(diff, &tuple);
- result = ISC_R_SUCCESS;
+ result = addrdata(&dnskey, diff, origin, ttl, mctx);
failure:
return (result);
void (*report)(const char *, ...))
{
isc_result_t result;
- dns_difftuple_t *tuple = NULL;
unsigned char buf[DST_KEY_MAXSIZE];
dns_rdata_t dnskey = DNS_RDATA_INIT;
char alg[80];
reason, dst_key_id(key->key), alg);
RETERR(make_dnskey(key->key, buf, sizeof(buf), &dnskey));
- RETERR(dns_difftuple_create(mctx, DNS_DIFFOP_DEL, origin, ttl, &dnskey,
- &tuple));
- dns_diff_appendminimal(diff, &tuple);
- result = ISC_R_SUCCESS;
+ result = delrdata(&dnskey, diff, origin, ttl, mctx);
failure:
return (result);
if (!dns_rdataset_isassociated(cdnskey) ||
!exists(cdnskey, &cdnskeyrdata))
{
- RETERR(publish(&cdnskeyrdata, diff, origin,
- ttl, mctx));
+ RETERR(addrdata(&cdnskeyrdata, diff, origin,
+ ttl, mctx));
}
/* Only publish SHA-256 (SHA-1 is deprecated) */
if (!dns_rdataset_isassociated(cds) ||
!exists(cds, &cds_sha256))
{
- RETERR(publish(&cds_sha256, diff, origin,
- ttl, mctx));
+ RETERR(addrdata(&cds_sha256, diff, origin,
+ ttl, mctx));
}
}
(key->key_flags & DNS_KEYFLAG_TYPEMASK) != DNS_KEYTYPE_NOKEY)
return (key->func->tofile(key, directory));
else
- return (ISC_R_SUCCESS);
+ return (ret);
}
void
REQUIRE(iteratorp != NULL);
REQUIRE(DNS_RDATASETITER_VALID(*iteratorp));
+ /* cppcheck-suppress unreadVariable */
u.rdatasetiterator = *iteratorp;
+ *iteratorp = NULL;
mctx = u.ecdbiterator->common.db->mctx;
u.ecdbiterator->common.magic = 0;
&u.ecdbiterator->common.node);
isc_mem_put(mctx, u.ecdbiterator,
sizeof(ecdb_rdatasetiter_t));
-
- *iteratorp = NULL;
}
static isc_result_t
isc_buffer_init(&buf, cp, size - 1);
result = dns_name_totext(name, true, &buf);
if (result == ISC_R_SUCCESS) {
- /*
- * Null terminate.
- */
- isc_region_t r;
- isc_buffer_usedregion(&buf, &r);
- ((char *) r.base)[r.length] = '\0';
-
- } else
+ isc_buffer_putuint8(&buf, (uint8_t)'\0');
+ } else {
snprintf(cp, size, "<unknown>");
+ }
}
/*
unsigned int max_type;
dns_rdatasetiter_t *rdsiter;
+ REQUIRE(target != NULL);
+
memset(buffer, 0, DNS_NSEC_BUFFERSIZE);
dns_name_toregion(target, &r);
memmove(buffer, r.base, r.length);
UNUSED(n);
+ /* cppcheck-suppress unreadVariable */
u.dptr = BN_GENCB_get_arg(cb);
if (u.fptr != NULL)
u.fptr(p);
if (callback == NULL) {
BN_GENCB_set_old(cb, NULL, NULL);
} else {
+ /* cppcheck-suppress unreadVariable */
u.fptr = callback;
BN_GENCB_set(cb, &progress_cb, u.dptr);
}
UNUSED(n);
+ /* cppcheck-suppress unreadVariable */
u.dptr = BN_GENCB_get_arg(cb);
if (u.fptr != NULL)
u.fptr(p);
if (callback == NULL) {
BN_GENCB_set_old(cb, NULL, NULL);
} else {
+ /* cppcheck-suppress unreadVariable */
u.fptr = callback;
BN_GENCB_set(cb, &progress_cb, u.dptr);
}
void
dns_rbt_printnodeinfo(dns_rbtnode_t *n, FILE *f) {
+
+ if (n == NULL) {
+ fprintf(f, "Null node\n");
+ return;
+ }
+
fprintf(f, "Node info for nodename: ");
printnodename(n, true, f);
fprintf(f, "\n");
fprintf(f, "Right: %p\n", n->right);
fprintf(f, "Left: %p\n", n->left);
fprintf(f, "Down: %p\n", n->down);
- fprintf(f, "daTa: %p\n", n->data);
+ fprintf(f, "Data: %p\n", n->data);
}
static void
if (root != NULL) {
printnodename(root, true, f);
+ /*
+ * Don't use IS_RED(root) as it tests for 'root != NULL'
+ * and cppcheck produces false positives.
+ */
fprintf(f, " (%s, %s", direction,
- IS_RED(root) ? "RED" : "BLACK");
+ COLOR(root) == RED ? "RED" : "BLACK");
if ((! IS_ROOT(root) && PARENT(root) != parent) ||
( IS_ROOT(root) && depth > 0 &&
depth++;
- if (IS_RED(root) && IS_RED(LEFT(root)))
+ /*
+ * Don't use IS_RED(root) as it tests for 'root != NULL'
+ * and cppcheck produces false positives.
+ */
+ if (COLOR(root) == RED && IS_RED(LEFT(root))) {
fprintf(f, "** Red/Red color violation on left\n");
+ }
print_text_helper(LEFT(root), root, depth, "left",
data_printer, f);
- if (IS_RED(root) && IS_RED(RIGHT(root)))
+ /*
+ * Don't use IS_RED(root) as cppcheck produces false positives.
+ */
+ if (COLOR(root) == RED && IS_RED(RIGHT(root))) {
fprintf(f, "** Red/Red color violation on right\n");
+ }
print_text_helper(RIGHT(root), root, depth, "right",
data_printer, f);
result = dns_secalg_totext(alg, &b);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
+ /* cppcheck-suppress unreadVariable */
r.base[0] = 0;
+ }
}
isc_result_t
{
isc_result_t result;
char *text, *end;
- unsigned int value, mask;
+ unsigned int value = 0;
+#ifdef notyet
+ unsigned int mask = 0;
+#endif
result = maybe_numeric(&value, source, 0xffff, true);
if (result == ISC_R_SUCCESS) {
text = source->base;
end = source->base + source->length;
- value = mask = 0;
while (text < end) {
struct keyflag *p;
#ifdef notyet
if ((mask & p->mask) != 0)
warn("overlapping key flags");
-#endif
mask |= p->mask;
+#endif
text += len;
if (delim != NULL)
text++; /* Skip "|" */
result = dns_dsdigest_totext(typ, &b);
isc_buffer_usedregion(&b, &r);
r.base[r.length] = 0;
- if (result != ISC_R_SUCCESS)
+ if (result != ISC_R_SUCCESS) {
+ /* cppcheck-suppress unreadVariable */
r.base[0] = 0;
+ }
}
/*
mock_assert(has_enough_memory, "mock isc_mem_get failed",
__FILE__, __LINE__);
+ /* cppcheck-suppress leakNoVarFunctionCall */
return (malloc(size));
}
* here because region.base is type unsigned char *.
*/
isc_buffer_usedregion(target, ®ion);
+ /* cppcheck-suppress unreadVariable */
region.base[region.length - 1] =
toupper(region.base[region.length - 1]);
}
static inline bool
was_dumping(dns_zone_t *zone) {
- bool dumping;
REQUIRE(LOCKED_ZONE(zone));
- dumping = DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING);
- DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_DUMPING);
- if (!dumping) {
- DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
- isc_time_settoepoch(&zone->dumptime);
+ if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_DUMPING)) {
+ return (true);
}
- return (dumping);
+
+ DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_DUMPING);
+ DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NEEDDUMP);
+ isc_time_settoepoch(&zone->dumptime);
+ return (false);
}
/*%
get_win32_searchlist(irs_resconf_t *conf) {
isc_result_t result = ISC_R_SUCCESS;
HKEY hKey;
- BOOL keyFound = TRUE;
char searchlist[MAX_PATH];
DWORD searchlen = MAX_PATH;
LSTATUS status;
FATAL_ERROR(__FILE__, __LINE__,
"Unexpected state %d",
state);
- ISC_UNREACHABLE();
}
} while (!done);
static void
ratelimiter_tick(isc_task_t *task, isc_event_t *event) {
- isc_result_t result = ISC_R_SUCCESS;
isc_ratelimiter_t *rl = (isc_ratelimiter_t *)event->ev_arg;
isc_event_t *p;
uint32_t pertic;
*/
ISC_LIST_UNLINK(rl->pending, p, ev_ratelink);
} else {
+ isc_result_t result;
/*
* No work left to do. Stop the timer so that we don't
* waste resources by having it fire periodically.
*/
isc_buffer_availableregion(target, &avail);
INSIST(avail.length >= 1);
+ /* cppcheck-suppress unreadVariable */
avail.base[0] = '\0';
return (ISC_R_SUCCESS);
static void
isc_hmac_reset_test(void **state) {
isc_hmac_t *hmac = *state;
+#if 0
unsigned char digest[ISC_MAX_MD_SIZE] __attribute((unused));
unsigned int digestlen __attribute((unused));
+#endif
assert_non_null(hmac);
static void
isc_md_reset_test(void **state) {
isc_md_t *md = *state;
+#if 0
unsigned char digest[ISC_MAX_MD_SIZE] __attribute((unused));
unsigned int digestlen __attribute((unused));
+#endif
assert_non_null(md);
assert_non_null(p);
assert_int_equal(p->value, 5);
+ assert_null(queue.head);
+ assert_null(queue.tail);
assert_true(ISC_QUEUE_EMPTY(queue));
ISC_QUEUE_DESTROY(queue);
/* Preconditions (section 2.2.7 in NIST SP 800-22) */
assert_true(numbits >= 100);
+ /* cppcheck-suppress constArgument */
assert_true(mbits >= 20);
assert_true((double) mbits > (0.01 * numbits));
assert_true(numblocks < 100);
j += 100;
}
+ UNUSED(j);
+
if (verbose) {
print_message("# task %s\n", (char *)event->ev_arg);
}
return (ISC_R_SUCCESS);
}
#endif
+ /* cppcheck-suppress duplicateCondition */
if (resource == isc_resource_openfiles && rlim_value == RLIM_INFINITY) {
if (getrlimit(unixresource, &rl) == 0) {
rl.rlim_cur = rl.rlim_max;
isc_result_t
isc_file_renameunique(const char *file, char *templet) {
int fd;
- int res = 0;
isc_result_t result = ISC_R_SUCCESS;
REQUIRE(file != NULL);
close(fd);
if (result == ISC_R_SUCCESS) {
+ int res;
res = isc_file_safemovefile(file, templet);
if (res != 0) {
result = isc__errno2result(errno);
ioctl_failure:
if (iter->buf4 != NULL)
isc_mem_put(mctx, iter->buf4, iter->buf4size);
-
- alloc_failure:
if (iter->socket != INVALID_SOCKET)
(void) closesocket(iter->socket);
#define MAX_NAME_LENGTH 256
+#define CHECK(op) \
+ do { result = (op); if (result != ISC_R_SUCCESS) { goto cleanup; } } while (0)
+
isc_result_t
isc_ntsecurity_getaccountgroups(char *username, char **GroupList,
unsigned int maxgroups,
- unsigned int *totalGroups) {
+ unsigned int *totalGroups)
+{
LPGROUP_USERS_INFO_0 pTmpBuf;
LPLOCALGROUP_USERS_INFO_0 pTmpLBuf;
DWORD i;
NET_API_STATUS nStatus;
size_t retlen;
wchar_t user[MAX_NAME_LENGTH];
+ isc_result_t result;
+
+ *totalGroups = 0;
retlen = mbstowcs(user, username, MAX_NAME_LENGTH);
+ if (retlen == (size_t) (-1)) {
+ return (ISC_R_FAILURE);
+ }
- *totalGroups = 0;
/*
* Call the NetUserGetLocalGroups function
* specifying information level 0.
* function should also return the names of the local
* groups in which the user is indirectly a member.
*/
- nStatus = NetUserGetLocalGroups(NULL,
- user,
- dwLevel,
- dwFlags,
- (LPBYTE *) &pBuf,
- dwPrefMaxLen,
- &dwEntriesRead,
- &dwTotalEntries);
+ nStatus = NetUserGetLocalGroups(NULL, user, dwLevel, dwFlags,
+ (LPBYTE *) &pBuf, dwPrefMaxLen,
+ &dwEntriesRead, &dwTotalEntries);
/*
* See if the call succeeds,
*/
if (nStatus != NERR_Success) {
- if (nStatus == ERROR_ACCESS_DENIED)
+ if (nStatus == ERROR_ACCESS_DENIED) {
return (ISC_R_NOPERM);
- if (nStatus == ERROR_MORE_DATA)
+ }
+ if (nStatus == ERROR_MORE_DATA) {
return (ISC_R_NOSPACE);
- if (nStatus == NERR_UserNotFound)
+ }
+ if (nStatus == NERR_UserNotFound) {
dwEntriesRead = 0;
+ }
}
if (pBuf != NULL) {
for (i = 0;
(i < dwEntriesRead && *totalGroups < maxgroups); i++) {
assert(pTmpLBuf != NULL);
- if (pTmpLBuf == NULL)
+ if (pTmpLBuf == NULL) {
break;
+ }
retlen = wcslen(pTmpLBuf->lgrui0_name);
GroupList[*totalGroups] = (char *) malloc(retlen +1);
- if (GroupList[*totalGroups] == NULL)
- return (ISC_R_NOMEMORY);
+ if (GroupList[*totalGroups] == NULL) {
+ CHECK(ISC_R_NOMEMORY);
+ }
retlen = wcstombs(GroupList[*totalGroups],
- pTmpLBuf->lgrui0_name, retlen);
+ pTmpLBuf->lgrui0_name, retlen);
+ if (retlen == (size_t) (-1)) {
+ free(GroupList[*totalGroups]);
+ CHECK(ISC_R_FAILURE);
+ }
GroupList[*totalGroups][retlen] = '\0';
- if (strcmp(GroupList[*totalGroups], "None") == 0)
+ if (strcmp(GroupList[*totalGroups], "None") == 0) {
free(GroupList[*totalGroups]);
- else
+ } else {
(*totalGroups)++;
+ }
pTmpLBuf++;
}
}
/* Free the allocated memory. */
+ /* cppcheck-suppress duplicateCondition */
if (pBuf != NULL)
NetApiBufferFree(pBuf);
/*
* Call the NetUserGetGroups function, specifying level 0.
*/
- nStatus = NetUserGetGroups(NULL,
- user,
- dwLevel,
- (LPBYTE*)&pgrpBuf,
- dwPrefMaxLen,
- &dwEntriesRead,
- &dwTotalEntries);
+ nStatus = NetUserGetGroups(NULL, user, dwLevel,
+ (LPBYTE*)&pgrpBuf, dwPrefMaxLen,
+ &dwEntriesRead, &dwTotalEntries);
/*
* See if the call succeeds,
*/
if (nStatus != NERR_Success) {
- if (nStatus == ERROR_ACCESS_DENIED)
+ if (nStatus == ERROR_ACCESS_DENIED) {
return (ISC_R_NOPERM);
- if (nStatus == ERROR_MORE_DATA)
+ }
+ if (nStatus == ERROR_MORE_DATA) {
return (ISC_R_NOSPACE);
- if (nStatus == NERR_UserNotFound)
+ }
+ if (nStatus == NERR_UserNotFound) {
dwEntriesRead = 0;
+ }
}
if (pgrpBuf != NULL) {
(i < dwEntriesRead && *totalGroups < maxgroups); i++) {
assert(pTmpBuf != NULL);
- if (pTmpBuf == NULL)
+ if (pTmpBuf == NULL) {
break;
+ }
retlen = wcslen(pTmpBuf->grui0_name);
GroupList[*totalGroups] = (char *) malloc(retlen +1);
- if (GroupList[*totalGroups] == NULL)
- return (ISC_R_NOMEMORY);
+ if (GroupList[*totalGroups] == NULL) {
+ CHECK(ISC_R_NOMEMORY);
+ }
retlen = wcstombs(GroupList[*totalGroups],
pTmpBuf->grui0_name, retlen);
+ if (retlen == (size_t) (-1)) {
+ free(GroupList[*totalGroups]);
+ CHECK(ISC_R_FAILURE);
+ }
GroupList[*totalGroups][retlen] = '\0';
- if (strcmp(GroupList[*totalGroups], "None") == 0)
+ if (strcmp(GroupList[*totalGroups], "None") == 0) {
free(GroupList[*totalGroups]);
- else
+ } else {
(*totalGroups)++;
+ }
pTmpBuf++;
}
}
/*
* Free the allocated memory.
*/
- if (pgrpBuf != NULL)
+ /* cppcheck-suppress duplicateCondition */
+ if (pgrpBuf != NULL) {
NetApiBufferFree(pgrpBuf);
+ }
return (ISC_R_SUCCESS);
+
+ cleanup:
+ while (--(*totalGroups) > 0) {
+ free(GroupList[*totalGroups]);
+ }
+ return (result);
}
static isc_result_t
allocate_socket(isc_socketmgr_t *manager, isc_sockettype_t type,
- isc_socket_t **socketp) {
+ isc_socket_t **socketp)
+{
isc_socket_t *sock;
- isc_result_t result;
sock = isc_mem_get(manager->mctx, sizeof(*sock));
*socketp = sock;
return (ISC_R_SUCCESS);
-
- error:
- if (sock->recvbuf.base != NULL)
- isc_mem_put(manager->mctx, sock->recvbuf.base, sock->recvbuf.len);
- isc_mem_put(manager->mctx, sock, sizeof(*sock));
-
- return (result);
}
/*
static isc_threadresult_t WINAPI
SocketIoThread(LPVOID ThreadContext) {
isc_socketmgr_t *manager = ThreadContext;
- BOOL bSuccess = FALSE;
DWORD nbytes;
IoCompletionInfo *lpo = NULL;
isc_socket_t *sock = NULL;
* Loop forever waiting on I/O Completions and then processing them
*/
while (TRUE) {
+ BOOL bSuccess;
+
wait_again:
bSuccess = GetQueuedCompletionStatus(manager->hIoCompletionPort,
&nbytes,
_set_state(sock, SOCK_CLOSED);
}
how &= ~ISC_SOCKCANCEL_CONNECT;
+ UNUSED(how);
maybe_free_socket(&sock, __LINE__);
}
i1.LowPart = temp.dwLowDateTime;
i1.HighPart = temp.dwHighDateTime;
+ /* cppcheck-suppress unreadVariable */
i1.QuadPart += (unsigned __int64)nanoseconds/100;
+ /* cppcheck-suppress unreadVariable */
i1.QuadPart += (unsigned __int64)seconds*10000000;
t->absolute.dwLowDateTime = i1.LowPart;
if (UINT64_MAX - i1.QuadPart < (unsigned __int64)i->interval)
return (ISC_R_RANGE);
+ /* cppcheck-suppress unreadVariable */
i1.QuadPart += i->interval;
t->absolute.dwLowDateTime = i1.LowPart;
if (UINT64_MAX - i1.QuadPart < (unsigned __int64)i->interval)
return (ISC_R_RANGE);
+ /* cppcheck-suppress unreadVariable */
i1.QuadPart += i->interval;
result->absolute.dwLowDateTime = i1.LowPart;
if (i1.QuadPart < (unsigned __int64) i->interval)
return (ISC_R_RANGE);
+ /* cppcheck-suppress unreadVariable */
i1.QuadPart -= i->interval;
result->absolute.dwLowDateTime = i1.LowPart;
REQUIRE(t1 != NULL && t2 != NULL);
+ /* cppcheck-suppress unreadVariable */
i1.LowPart = t1->absolute.dwLowDateTime;
+ /* cppcheck-suppress unreadVariable */
i1.HighPart = t1->absolute.dwHighDateTime;
+ /* cppcheck-suppress unreadVariable */
i2.LowPart = t2->absolute.dwLowDateTime;
+ /* cppcheck-suppress unreadVariable */
i2.HighPart = t2->absolute.dwHighDateTime;
if (i1.QuadPart <= i2.QuadPart)
SystemTimeToFileTime(&epoch1970, &temp);
+ /* cppcheck-suppress unreadVariable */
i1.LowPart = t->absolute.dwLowDateTime;
+ /* cppcheck-suppress unreadVariable */
i1.HighPart = t->absolute.dwHighDateTime;
+ /* cppcheck-suppress unreadVariable */
i2.LowPart = temp.dwLowDateTime;
+ /* cppcheck-suppress unreadVariable */
i2.HighPart = temp.dwHighDateTime;
i3 = (i1.QuadPart - i2.QuadPart) / 10000000;
default:
return (ISC_R_FAILURE);
}
- if (value > UINT64_MAX / unit)
+ if (value > ((uint64_t)UINT64_MAX / unit)) {
return (ISC_R_FAILURE);
+ }
*valuep = value * unit;
return (ISC_R_SUCCESS);
}
void
cfg_print_mapbody(cfg_printer_t *pctx, const cfg_obj_t *obj) {
- isc_result_t result = ISC_R_SUCCESS;
const cfg_clausedef_t * const *clauseset;
REQUIRE(pctx != NULL);
for (clause = *clauseset;
clause->name != NULL;
clause++) {
+ isc_result_t result;
result = isc_symtab_lookup(obj->value.map.symtab,
clause->name, 0, &symval);
if (result == ISC_R_SUCCESS) {
if (client->nreads > 0) {
dns_tcpmsg_cancelread(&client->tcpmsg);
- }
-
- /* Still waiting for read cancel completion. */
- if (client->nreads > 0) {
- return (true);
+ /* Still waiting for read cancel completion? */
+ if (client->nreads > 0) {
+ return (true);
+ }
}
if (client->tcpmsg_valid) {
if (client->naccepts > 0) {
isc_socket_cancel(client->tcplistener, client->task,
ISC_SOCKCANCEL_ACCEPT);
- }
-
- /* Still waiting for accept cancel completion. */
- if (client->naccepts > 0) {
- return (true);
+ /* Still waiting for accept cancel completion? */
+ if (client->naccepts > 0) {
+ return (true);
+ }
}
/* Accept cancel is complete. */
if (client->nrecvs > 0) {
isc_socket_cancel(client->udpsocket, client->task,
ISC_SOCKCANCEL_RECV);
- }
-
- /* Still waiting for recv cancel completion. */
- if (client->nrecvs > 0) {
- return (true);
+ /* Still waiting for recv cancel completion? */
+ if (client->nrecvs > 0) {
+ return (true);
+ }
}
/* Still waiting for control event to be delivered */
isc_netaddr_t netaddr;
int match;
unsigned int sockflags = ISC_SOCKFLAG_IMMEDIATE;
- isc_dscp_t dispdscp = -1;
if (TCP_CLIENT(client)) {
sock = client->tcpsocket;
pktinfo = NULL;
if (client->dispatch != NULL) {
- dispdscp = dns_dispatch_getdscp(client->dispatch);
- if (dispdscp != -1)
- client->dscp = dispdscp;
+ isc_dscp_t dscp = dns_dispatch_getdscp(client->dispatch);
+ if (dscp != -1) {
+ client->dscp = dscp;
+ }
}
if (client->dscp == -1) {
ev = &client->ctlevent;
isc_task_send(client->task, &ev);
- return (ISC_R_SUCCESS);
+ return (result);
}
static isc_result_t
ev = &client->ctlevent;
isc_task_send(client->task, &ev);
- return (ISC_R_SUCCESS);
+ return (result);
}
isc_result_t
*clientp = client;
- return (ISC_R_SUCCESS);
+ return (result);
}
isc_result_t
const char *signer = "", *qname = "";
dns_name_t *q = NULL;
+ REQUIRE(client != NULL);
+
vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap);
if (client->signer != NULL) {