Page MenuHome GnuPG

Misbehaving Solaris g_utf8_validate() commands causes pinentry-gtk-2 to hang and segfault
Closed, ResolvedPublic

Description

On a misbehaving Solaris x86 (5.10 Generic_141415-07) system I observed
pinentry-gtk-2 repeatedly hang and segfault, and digging into the problem I
observed that this was caused by the fact that g_utf8_validate() was returning
false and setting the pointer supplied in the third argument to the null at
the end of the string. I can only guess that the Sun library is not
recognizing the terminating NULL at the end of the string as THE end of the
string, but regardless this problem caused pinentry-gtk-2 to replace the null
with the '?' character and resume the effort looking for invalid characters,
gradually replacing every NULL it could find until the process inevitably
segfaulted.

I applied the following patch to work around the problem, but it may not be
the best fix - I'm interested to hear what you think is the best way to
address this problem.

Thanks,

  • Michael
  • gtk+-2/pinentry-gtk-2.c.orig Thu Mar 17 14:09:20 2011
  • gtk+-2/pinentry-gtk-2.c Thu Mar 17 14:10:50 2011 ***
  • 229,238 **** if (!result) { gchar *p;

    result = p = g_strdup (text);

! while (!g_utf8_validate (p, -1, (const gchar **) &p))
! *p = '?';

    }
  return result;
}
  • 229,240 ---- if (!result) { gchar *p;

+ gchar *maxp;

result = p = g_strdup (text);

! maxp = strchr (p, NULL);
! while (p < maxp && !g_utf8_validate (p, -1, (const gchar **) &p))
! if (p < maxp) *p = '?';

    }
  return result;
}

Details

Version
0.8.1

Event Timeline

werner claimed this task.

The report is quite old.
Let's assume that has been fixed by newer gtk versions.