From e6ed10f25e4b2ea791d8e52253f7d806316420e9 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Mon, 6 Jan 2020 22:57:05 +0000 Subject: lib9, libndb: exclude terminating null from strncpy bound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC pointed this out with some "warning: ‘strncpy’ specified bound NUM equals destination size [-Wstringop-truncation]" warnings. Change-Id: Id8408b165f6e4ae82c96a77599d89f658d979b32 --- src/libndb/sysdnsquery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libndb') diff --git a/src/libndb/sysdnsquery.c b/src/libndb/sysdnsquery.c index b9661be1..0a771e2b 100644 --- a/src/libndb/sysdnsquery.c +++ b/src/libndb/sysdnsquery.c @@ -84,7 +84,7 @@ mkptrname(char *ip, char *rip, int rlen) static void nstrcpy(char *to, char *from, int len) { - strncpy(to, from, len); + strncpy(to, from, len-1); to[len-1] = 0; } -- cgit v1.2.3 From fa325e9b42b0bdfb48857d1958d9fb7ceac55151 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Fri, 10 Jan 2020 14:44:21 +0000 Subject: Trivial changes: whitespace and modes. Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross --- src/libndb/csipinfo.c | 2 +- src/libndb/dnsquery.c | 4 ++-- src/libndb/ndbaux.c | 2 +- src/libndb/ndbcache.c | 2 +- src/libndb/ndbfree.c | 2 +- src/libndb/ndbhash.c | 4 ++-- src/libndb/ndbopen.c | 2 +- src/libndb/ndbreorder.c | 2 +- src/libndb/sysdnsquery.c | 32 ++++++++++++++++---------------- src/libndb/testdns.c | 9 ++++----- 10 files changed, 30 insertions(+), 31 deletions(-) (limited to 'src/libndb') diff --git a/src/libndb/csipinfo.c b/src/libndb/csipinfo.c index 76f3d8e0..6ffaf172 100644 --- a/src/libndb/csipinfo.c +++ b/src/libndb/csipinfo.c @@ -34,7 +34,7 @@ csipinfo(char *netroot, char *attr, char *val, char **list, int n) break; p = seprint(p, e, " %s", *list++); } - + if(write(fd, line, strlen(line)) < 0){ close(fd); return 0; diff --git a/src/libndb/dnsquery.c b/src/libndb/dnsquery.c index 4cf8735a..74460b14 100644 --- a/src/libndb/dnsquery.c +++ b/src/libndb/dnsquery.c @@ -119,11 +119,11 @@ doquery(int fd, char *dn, char *type) snprint(buf, sizeof(buf), "!%s %s", dn, type); if(write(fd, buf, strlen(buf)) < 0) return nil; - + seek(fd, 0, 0); first = last = nil; - + for(;;){ n = read(fd, buf, sizeof(buf)-2); if(n <= 0) diff --git a/src/libndb/ndbaux.c b/src/libndb/ndbaux.c index 94246fc6..a2688736 100644 --- a/src/libndb/ndbaux.c +++ b/src/libndb/ndbaux.c @@ -60,7 +60,7 @@ _ndbparsetuple(char *cp, Ndbtuple **tp) } /* - * parse all tuples in a line. we assume that the + * parse all tuples in a line. we assume that the * line ends in a '\n'. * * the tuples are linked as a list using ->entry and diff --git a/src/libndb/ndbcache.c b/src/libndb/ndbcache.c index 80dbc35b..d02530f5 100644 --- a/src/libndb/ndbcache.c +++ b/src/libndb/ndbcache.c @@ -9,7 +9,7 @@ struct Ndbcache char *attr; char *val; Ndbs s; - Ndbtuple *t; + Ndbtuple *t; }; enum diff --git a/src/libndb/ndbfree.c b/src/libndb/ndbfree.c index 647bff03..50626131 100644 --- a/src/libndb/ndbfree.c +++ b/src/libndb/ndbfree.c @@ -61,5 +61,5 @@ ndbnew(char *attr, char *val) t->val = t->valbuf; if(val != nil) ndbsetval(t, val, strlen(val)); - return t; + return t; } diff --git a/src/libndb/ndbhash.c b/src/libndb/ndbhash.c index 4f9cb4b6..8dee18a5 100644 --- a/src/libndb/ndbhash.c +++ b/src/libndb/ndbhash.c @@ -198,7 +198,7 @@ ndbsnext(Ndbs *s, char *attr, char *val) ndbfree(t); } else if(s->type == Cptr){ if(Bseek(&db->b, s->ptr, 0) < 0) - break; + break; s->ptr = s->ptr1; s->type = Cptr1; t = ndbparse(db); @@ -218,7 +218,7 @@ ndbsnext(Ndbs *s, char *attr, char *val) s->type = Cptr; } else { /* end of hash chain */ if(Bseek(&db->b, s->ptr, 0) < 0) - break; + break; s->ptr = NDBNAP; t = ndbparse(db); if(t == 0) diff --git a/src/libndb/ndbopen.c b/src/libndb/ndbopen.c index fdda79ec..1002b4d6 100644 --- a/src/libndb/ndbopen.c +++ b/src/libndb/ndbopen.c @@ -77,7 +77,7 @@ doopen(char *file, char *rel) * Unrooted paths are taken relative to db we opened. */ if(file[0]!='/' && rel && (p=strrchr(rel, '/'))!=nil) - snprint(db->file, sizeof(db->file), "%.*s/%s", + snprint(db->file, sizeof(db->file), "%.*s/%s", utfnlen(rel, p-rel), rel, file); else strncpy(db->file, file, sizeof(db->file)-1); diff --git a/src/libndb/ndbreorder.c b/src/libndb/ndbreorder.c index 390d7818..c25d7b5f 100644 --- a/src/libndb/ndbreorder.c +++ b/src/libndb/ndbreorder.c @@ -27,7 +27,7 @@ ndbreorder(Ndbtuple *t, Ndbtuple *x) for(nt = t; nt->entry != last->line; nt = nt->entry) ; nt->entry = nil; - + /* switch */ for(nt = last; nt->entry != nil; nt = nt->entry) ; diff --git a/src/libndb/sysdnsquery.c b/src/libndb/sysdnsquery.c index 0a771e2b..1f6cbb58 100644 --- a/src/libndb/sysdnsquery.c +++ b/src/libndb/sysdnsquery.c @@ -20,11 +20,11 @@ Ndbtuple* dnsquery(char *net, char *val, char *type) { static int init; - char rip[128]; + char rip[128]; Ndbtuple *t; USED(net); - + if(!init){ init = 1; fmtinstall('I', eipfmt); @@ -32,17 +32,17 @@ dnsquery(char *net, char *val, char *type) /* give up early on stupid questions - vwhois */ if(strcmp(val, "::") == 0 || strcmp(val, "0.0.0.0") == 0) return nil; - + /* zero out the error string */ werrstr(""); - + /* if this is a reverse lookup, first look up the domain name */ if(strcmp(type, "ptr") == 0){ mkptrname(val, rip, sizeof rip); t = doquery(rip, "ptr"); }else t = doquery(val, type); - + return t; } @@ -123,7 +123,7 @@ enum /* query types (all RR types are also queries) */ Tixfr= 251, /* incremental zone transfer */ Taxfr= 252, /* zone transfer */ - Tmailb= 253, /* { Tmb, Tmg, Tmr } */ + Tmailb= 253, /* { Tmb, Tmg, Tmr } */ Tall= 255, /* all records */ /* classes */ @@ -173,7 +173,7 @@ doquery(char *name, char *type) qdcount = (buf[4]<<8)|buf[5]; ancount = (buf[6]<<8)|buf[7]; - + p = buf+12; p = skipquestion(buf, buf+n, p, qdcount); p = unpack(buf, buf+n, p, &t, ancount); @@ -215,7 +215,7 @@ static char* type2name(int t) { int i; - + for(i=0; ientry){ print("%s=%q ", t->attr, t->val); if(t->line == t0){ @@ -32,4 +32,3 @@ main(int argc, char **argv) } exits(0); } - -- cgit v1.2.3