commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

hurd/boot boot_script.c


From: Roland McGrath
Subject: hurd/boot boot_script.c
Date: Sat, 04 Jan 2003 16:30:10 -0500

CVSROOT:        /cvsroot/hurd
Module name:    hurd
Changes by:     Roland McGrath <address@hidden> 03/01/04 16:30:10

Modified files:
        boot           : boot_script.c 

Log message:
        2003-01-04  Roland McGrath  <address@hidden>
        
        * boot_script.c (boot_script_parse_line): Copy the file name into
        malloc'd storage.
        (add_arg): New arg TEXTLEN.  Store malloc'd copy of TEXT.
        (boot_script_parse_line): Update callers.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/hurd/hurd/boot/boot_script.c.diff?tr1=1.14&tr2=1.15&r1=text&r2=text

Patches:
Index: hurd/boot/boot_script.c
diff -u hurd/boot/boot_script.c:1.14 hurd/boot/boot_script.c:1.15
--- hurd/boot/boot_script.c:1.14        Tue May 28 22:42:34 2002
+++ hurd/boot/boot_script.c     Sat Jan  4 16:30:10 2003
@@ -175,14 +175,14 @@
 /* Create an argument with TEXT, value type TYPE, and value VAL.
    Add the argument to the argument list of CMD.  */
 static struct arg *
-add_arg (struct cmd *cmd, char *text, int type, int val)
+add_arg (struct cmd *cmd, const char *text, int textlen, int type, int val)
 {
   struct arg *arg;
 
-  arg = boot_script_malloc (sizeof (struct arg));
+  arg = boot_script_malloc (sizeof (struct arg) + textlen);
   if (arg)
     {
-      arg->text = text;
+      arg->text = text == 0 ? 0 : memcpy (arg + 1, text, textlen);
       arg->type = type;
       arg->val = val;
       if (add_list (arg, (void ***) &cmd->args,
@@ -255,16 +255,16 @@
   if (p == q)
       return 0;
 
-  *q = '\0';
+  *q++ = '\0';
 
   /* Allocate a command structure.  */
-  cmd = boot_script_malloc (sizeof (struct cmd));
+  cmd = boot_script_malloc (sizeof (struct cmd) + (q - p));
   if (! cmd)
     return BOOT_SCRIPT_NOMEM;
   memset (cmd, 0, sizeof (struct cmd));
   cmd->hook = hook;
-  cmd->path = p;
-  p = q + 1;
+  cmd->path = memcpy (cmd + 1, p, q - p);
+  p = q;
 
   for (arg = 0;;)
     {
@@ -408,7 +408,7 @@
                     associated with an argument.  */
                  if (! arg && end_char == '}')
                    {
-                     if (! add_arg (cmd, 0, type, val))
+                     if (! add_arg (cmd, 0, 0, type, val))
                        {
                          error = BOOT_SCRIPT_NOMEM;
                          goto bad;
@@ -437,7 +437,7 @@
          *q = '\0';
 
          /* Add argument to list.  */
-         arg = add_arg (cmd, p, VAL_NONE, 0);
+         arg = add_arg (cmd, p, q + 1 - p, VAL_NONE, 0);
          if (! arg)
            {
              error = BOOT_SCRIPT_NOMEM;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]