~ubuntu-branches/ubuntu/oneiric/gnomebaker/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/02_fix_fstab_parsing.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Goedson Teixeira Paixao
  • Date: 2007-10-23 17:59:19 UTC
  • Revision ID: james.westby@ubuntu.com-20071023175919-wuvxkuwkxfe25oub
Tags: 0.6.2-3
debian/patches/02_fix_fstab_parsing.dpatch: Fixes the /etc/fstab
file parsing, dynamically allocating memory for each field to avoid
crashing when parsing lines with too long device names or mount
points (Closes: #447568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 02_fix_fstab_parsing.dpatch by Goedson Teixeira Paixao <goedson@debian.org>
 
3
##
 
4
## DP: Make node and mount sizes dynamic so long device names in fstab won't make
 
5
## DP: us crash.
 
6
 
 
7
@DPATCH@
 
8
diff -urNad gnomebaker-0.6.2~/src/devices.c gnomebaker-0.6.2/src/devices.c
 
9
--- gnomebaker-0.6.2~/src/devices.c     2007-09-16 13:36:33.000000000 -0300
 
10
+++ gnomebaker-0.6.2/src/devices.c      2007-10-23 17:30:38.000000000 -0200
 
11
@@ -111,7 +111,10 @@
 
12
                g_strstrip(*line);
 
13
                if((*line)[0] != '#') /* ignore commented out lines */
 
14
                {
 
15
-                       gchar node[64], mount[64];
 
16
+                       gchar *node, *mount;
 
17
+                       int line_size = strlen(*line);
 
18
+                       node = g_new0(gchar, line_size);
 
19
+                       mount = g_new0(gchar, line_size);
 
20
                        if(sscanf(*line, "%s\t%s", node, mount) == 2)
 
21
                        {
 
22
                                GB_TRACE("devices_add_device - node [%s] mount [%s]\n", node, mount);
 
23
@@ -134,8 +137,14 @@
 
24
                                }
 
25
 
 
26
                                if(mount_point != NULL)
 
27
+                               {
 
28
+                                       g_free(node);
 
29
+                                       g_free(mount);
 
30
                                        break;
 
31
+                               }
 
32
                        }
 
33
+                       g_free(node);
 
34
+                       g_free(mount);
 
35
                }
 
36
                ++line;
 
37
        }