]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
no more strcpy in ldns-dpa
authorWouter Wijngaards <wouter@NLnetLabs.nl>
Fri, 16 Apr 2010 09:16:58 +0000 (09:16 +0000)
committerWouter Wijngaards <wouter@NLnetLabs.nl>
Fri, 16 Apr 2010 09:16:58 +0000 (09:16 +0000)
examples/ldns-dpa.c

index 6e0e98b96c85dc6a9396ef4b64064f5bc6c41059..1d761327da3c173e1c8067c2098c5cc44186e88d 100644 (file)
@@ -1850,8 +1850,7 @@ parse_match_expression(char *string)
                                                                        val = malloc(4);
                                                                        snprintf(val, 3, "%u", (unsigned int) lt->id);
                                                                } else {
-                                                                       val = malloc(strlen(str) - i + 1);
-                                                                       strcpy(val, &str[i]);
+                                                                       val = strdup(&str[i]);
                                                                }
                                                                break;
                                                        case TYPE_RCODE:
@@ -1860,13 +1859,11 @@ parse_match_expression(char *string)
                                                                        val = malloc(4);
                                                                        snprintf(val, 3, "%u", (unsigned int) lt->id);
                                                                } else {
-                                                                       val = malloc(strlen(str) - i + 1);
-                                                                       strcpy(val, &str[i]);
+                                                                       val = strdup(&str[i]);
                                                                }
                                                                break;
                                                        default:
-                                                               val = malloc(strlen(str) - i + 1);
-                                                               strcpy(val, &str[i]);
+                                                               val = strdup(&str[i]);
                                                                break;
                                                }
                                                mo->value = val;