]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
don't use strlcat with non NUL terminated strings rt45981_stage3
authorMark Andrews <marka@isc.org>
Fri, 15 Sep 2017 03:14:16 +0000 (13:14 +1000)
committerMark Andrews <marka@isc.org>
Fri, 15 Sep 2017 03:14:16 +0000 (13:14 +1000)
lib/dns/rcode.c
lib/dns/rdata.c
lib/dns/ttl.c

index 8cad290937ec8ed26d2d157bcebac8e7847096c8..aaec1afa1d0ec1a4e9e9cd0c313dc91cf164bd1b 100644 (file)
@@ -252,8 +252,8 @@ maybe_numeric(unsigned int *valuep, isc_textregion_t *source,
         * isc_parse_uint32().  isc_parse_uint32() requires
         * null termination, so we must make a copy.
         */
-       strlcpy(buffer, source->base,
-               ISC_MIN(source->length + 1, sizeof(buffer)));
+       snprintf(buffer, sizeof(buffer), "%.*s",
+                (int)source->length, source->base);
 
        INSIST(buffer[source->length] == '\0');
 
@@ -508,8 +508,8 @@ dns_rdataclass_fromtext(dns_rdataclass_t *classp, isc_textregion_t *source) {
                         * source->base is not required to be NUL terminated.
                         * Copy up to remaining bytes and NUL terminate.
                         */
-                       strlcpy(buf, source->base + 5,
-                               ISC_MIN(source->length - 5 + 1, sizeof(buf)));
+                       snprintf(buf, sizeof(buf), "%.*s",
+                                (int)(source->length - 5), source->base + 5);
                        val = strtoul(buf, &endp, 10);
                        if (*endp == '\0' && val <= 0xffff) {
                                *classp = (dns_rdataclass_t)val;
index fd55eff695475045a2eb70c796279749de0dcc6b..f1c86e2dbf6a6a73eaed42459955e44f1a22b513 100644 (file)
@@ -1343,8 +1343,8 @@ dns_rdatatype_fromtext(dns_rdatatype_t *typep, isc_textregion_t *source) {
                 * source->base is not required to be NUL terminated.
                 * Copy up to remaining bytes and NUL terminate.
                 */
-               strlcpy(buf, source->base + 4,
-                       ISC_MIN(source->length - 4 + 1, sizeof(buf)));
+               snprintf(buf, sizeof(buf), "%.*s",
+                        (int)(source->length - 4), source->base + 4);
                val = strtoul(buf, &endp, 10);
                if (*endp == '\0' && val <= 0xffff) {
                        *typep = (dns_rdatatype_t)val;
index 1afca6426c424e770f29d9d55e816fd81cada328..06239c4dd2d3d4b592cf8e0bf747f820810ed194 100644 (file)
@@ -160,7 +160,7 @@ bind_ttl(isc_textregion_t *source, isc_uint32_t *ttl) {
        if (source->length > sizeof(buf) - 1)
                return (DNS_R_SYNTAX);
        /* Copy source->length bytes and NUL terminate. */
-       strlcpy(buf, source->base, ISC_MIN(source->length + 1, sizeof(buf)));
+       snprintf(buf, sizeof(buf), "%.*s", (int)source->length, source->base);
        s = buf;
 
        do {