]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Fix 8ec17063: "Lists_Add(): use size of destination when copying data"
authorAlexander Barton <alex@barton.de>
Wed, 18 Apr 2012 15:54:54 +0000 (17:54 +0200)
committerAlexander Barton <alex@barton.de>
Wed, 18 Apr 2012 15:54:54 +0000 (17:54 +0200)
Thanks to Florian Westphal for spotting my silliness ...

src/ngircd/lists.c

index 45a4874b6e94f268aa2a0942cdf249c4aec12a24..5c6c52c4c9b2c9f15a4bdddcd05bef422125b929 100644 (file)
@@ -147,11 +147,8 @@ Lists_Add(struct list_head *h, const char *Mask, time_t ValidUntil,
 
        strlcpy(newelem->mask, Mask, sizeof(newelem->mask));
        if (Reason) {
-               newelem->reason = malloc(strlen(Reason) + 1);
-               if (newelem->reason)
-                       strlcpy(newelem->reason, Reason,
-                               sizeof(newelem->reason));
-               else
+               newelem->reason = strdup(Reason);
+               if (!newelem->reason)
                        Log(LOG_EMERG,
                            "Can't allocate memory for new list reason text!");
        }