]> git.ipfire.org Git - thirdparty/mlmmj.git/commitdiff
getinfo: use strdup instead of malloc + strcpy
authorBaptiste Daroussin <bapt@FreeBSD.org>
Sat, 15 Apr 2023 19:32:22 +0000 (21:32 +0200)
committerBaptiste Daroussin <bapt@FreeBSD.org>
Sat, 15 Apr 2023 19:32:22 +0000 (21:32 +0200)
src/do_all_the_voodoo_here.c

index 2d38bfc00ba8e7de77561866120e0bfef29262b6..496924e68ca25f98451afa6913ffffd62142351f 100644 (file)
@@ -52,20 +52,17 @@ findit(const char *line, const strlist *headers)
 void getinfo(const char *line, struct mailhdr *readhdrs)
 {
        int i = 0;
-       size_t tokenlen, valuelen;
+       size_t tokenlen;
 
        while(readhdrs[i].token) {
                tokenlen = strlen(readhdrs[i].token);
                if(strncasecmp(line, readhdrs[i].token, tokenlen) == 0) {
                        readhdrs[i].valuecount++;
-                       valuelen = strlen(line) - tokenlen;
                        readhdrs[i].values =
                                (char **)xrealloc(readhdrs[i].values,
                                  readhdrs[i].valuecount * sizeof(char *));
                        readhdrs[i].values[readhdrs[i].valuecount - 1] =
-                                       (char *)xmalloc(valuelen + 1);
-                       strcpy(readhdrs[i].values[readhdrs[i].valuecount - 1],
-                                               line+tokenlen);
+                               xstrdup(line + tokenlen);
                }
                i++;
        }