Samuel Thibault <samuel.thiba...@gnu.org> wrote:

> ps -o %r
>
> hangs, could somebody have a look?

Here is a patch that should break the infinite loop.
--- hurd-0.6-old/libps/fmt.c    2015-04-19 16:24:54.000000000 +0300
+++ hurd-0.6/libps/fmt.c        2015-05-26 09:56:36.000000000 +0300
@@ -68,6 +68,8 @@
   src = new_fmt->src;
   while (*src != '\0')
     {
+      char *start = src;
+
       if (field - fields == fields_alloced)
        /* Time to grow FIELDS to make room for more.  */
        {
@@ -172,6 +174,19 @@
            /* This field spec doesn't have a name, so use its flags fields
               to set the global ones, and skip it.  */
            {
+             /* if we didn't use any chars, don't loop indefinitely */
+             if (src == start)
+               {
+                 if (err_string)
+                   asprintf (err_string, "%s: Unknown format spec", src);
+
+                 FREE (new_fmt->src);
+                 FREE (new_fmt);
+                 FREE (fields);
+
+                 return EINVAL;
+               }
+
              global_clr_flags = clr_flags;
              global_inv_flags = inv_flags;
              continue;

Reply via email to