]> sourceware.org Git - lvm2.git/commitdiff
Use fixed buffer to prevent stack overflow in persistent filter dump.
authorMilan Broz <mbroz@redhat.com>
Wed, 6 Jan 2010 13:25:36 +0000 (13:25 +0000)
committerMilan Broz <mbroz@redhat.com>
Wed, 6 Jan 2010 13:25:36 +0000 (13:25 +0000)
WHATS_NEW
lib/filters/filter-persistent.c

index 02065301126cd24360705cc07a4d1391a4887f7b..e955a8494304f43f6c7159a01a4e5ec99eb0168f 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.57 -
 ====================================
+  Use fixed buffer to prevent stack overflow in persistent filter dump.
   Use snapshot metadata usage to determine if a snapshot is empty.
   Insert missing stack macros to all activate_lv and deactivate_lv callers.
   Insert missing stack macros to all suspend_lv and resume_lv callers.
index d91ed1348e5654ec998de0ca59ca1f59c68e35e3..9243a9443b20424c51575799c43eebceb28969c8 100644 (file)
@@ -143,7 +143,7 @@ static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
 {
        void *d;
        int first = 1;
-       char *buf, *str;
+       char buf[2 * PATH_MAX];
        struct dm_hash_node *n;
 
        for (n = dm_hash_get_first(pf->devices); n;
@@ -160,13 +160,8 @@ static void _write_array(struct pfilter *pf, FILE *fp, const char *path,
                        first = 0;
                }
 
-               str = dm_hash_get_key(pf->devices, n);
-               if (!(buf = alloca(escaped_len(str)))) {
-                       log_error("persistent filter device path stack "
-                                 "allocation failed");
-                       return;
-               }
-               fprintf(fp, "\t\t\"%s\"", escape_double_quotes(buf, str));
+               escape_double_quotes(buf, dm_hash_get_key(pf->devices, n));
+               fprintf(fp, "\t\t\"%s\"", buf);
        }
 
        if (!first)
This page took 0.045905 seconds and 5 git commands to generate.