for(size_t i=0;i<glob_result.gl_pathc;i++) {
if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
DNSBackend::KeyData kd;
- kd.id = atoi(glob_result.gl_pathv[i]+regm[3].rm_so);
- kd.active = atoi(glob_result.gl_pathv[i]+regm[4].rm_so);
- kd.flags = atoi(glob_result.gl_pathv[i]+regm[2].rm_so);
+ kd.id = pdns_stou(glob_result.gl_pathv[i]+regm[3].rm_so);
+ kd.active = !strncmp(glob_result.gl_pathv[i]+regm[4].rm_so, "1", 1);
+ kd.flags = pdns_stou(glob_result.gl_pathv[i]+regm[2].rm_so);
ifstream ifs(glob_result.gl_pathv[i]);
ostringstream content;
char buffer[1024];
if (glob(pathname.str().c_str(),GLOB_ERR,NULL,&glob_result) == 0) {
for(size_t i=0;i<glob_result.gl_pathc;i++) {
if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
- unsigned int kid = atoi(glob_result.gl_pathv[i]+regm[3].rm_so);
+ unsigned int kid = pdns_stou(glob_result.gl_pathv[i]+regm[3].rm_so);
if (kid == id) {
if (unlink(glob_result.gl_pathv[i])) {
cerr << "Cannot delete key:" << strerror(errno) << endl;
int GeoIPBackend::addDomainKey(const DNSName& name, const KeyData& key) {
if (!d_dnssec) return false;
WriteLock rl(&s_state_lock);
- int nextid=1;
+ unsigned int nextid=1;
for(GeoIPDomain dom : s_domains) {
if (dom.domain == name) {
if (glob(pathname.str().c_str(),GLOB_ERR,NULL,&glob_result) == 0) {
for(size_t i=0;i<glob_result.gl_pathc;i++) {
if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
- int kid = atoi(glob_result.gl_pathv[i]+regm[3].rm_so);
+ unsigned int kid = pdns_stou(glob_result.gl_pathv[i]+regm[3].rm_so);
if (kid >= nextid) nextid = kid+1;
}
}
if (glob(pathname.str().c_str(),GLOB_ERR,NULL,&glob_result) == 0) {
for(size_t i=0;i<glob_result.gl_pathc;i++) {
if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
- unsigned int kid = atoi(glob_result.gl_pathv[i]+regm[3].rm_so);
- if (kid == id && atoi(glob_result.gl_pathv[i]+regm[4].rm_so) == 0) {
+ unsigned int kid = pdns_stou(glob_result.gl_pathv[i]+regm[3].rm_so);
+ if (kid == id && !strcmp(glob_result.gl_pathv[i]+regm[4].rm_so,"0")) {
ostringstream newpath;
- newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << atoi(glob_result.gl_pathv[i]+regm[2].rm_so) << "." << kid << ".1.key";
+ newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << pdns_stou(glob_result.gl_pathv[i]+regm[2].rm_so) << "." << kid << ".1.key";
if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) {
cerr << "Cannot active key: " << strerror(errno) << endl;
}
if (glob(pathname.str().c_str(),GLOB_ERR,NULL,&glob_result) == 0) {
for(size_t i=0;i<glob_result.gl_pathc;i++) {
if (regexec(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
- unsigned int kid = atoi(glob_result.gl_pathv[i]+regm[3].rm_so);
- if (kid == id && atoi(glob_result.gl_pathv[i]+regm[4].rm_so) == 1) {
+ unsigned int kid = pdns_stou(glob_result.gl_pathv[i]+regm[3].rm_so);
+ if (kid == id && !strcmp(glob_result.gl_pathv[i]+regm[4].rm_so,"1")) {
ostringstream newpath;
- newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << atoi(glob_result.gl_pathv[i]+regm[2].rm_so) << "." << kid << ".0.key";
+ newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << pdns_stou(glob_result.gl_pathv[i]+regm[2].rm_so) << "." << kid << ".0.key";
if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) {
cerr << "Cannot deactive key: " << strerror(errno) << endl;
}