This is the mail archive of the libc-hacker@sourceware.org mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix ld-time.c


Hi!

wformat and wname fields are used in:
      iov[2 + cnt].iov_base = (void *) time->era_entries[num].wname;
      iov[2 + cnt].iov_len = ((wcschr ((wchar_t *) time->era_entries[num].wformat, L'\0')
                               - (wchar_t *) time->era_entries[num].wname + 1)
                              * sizeof (uint32_t));
so, clearly neither should be NULL and both have to be in the same object.
The following patch attempts to do whatever we do for narrow name/format
(except the verbose warnings), i.e. if at least one of them is unspecified,
both are set to empty strings.

2006-05-11  Jakub Jelinek  <jakub@redhat.com>

	* locale/programs/ld-time.c (time_finish): If wide era name or
	format aren't provided, set both wname and wformat to L"".

--- libc/locale/programs/ld-time.c.jj	2006-05-10 14:03:49.000000000 +0200
+++ libc/locale/programs/ld-time.c	2006-05-11 16:50:11.000000000 +0200
@@ -467,15 +467,22 @@ No definition for %s category found"), "
 	  wstr = wstr ? wcschr (wstr + 1, L':') : NULL;	/* end offset */
 	  wstr = wstr ? wcschr (wstr + 1, L':') : NULL;	/* end start */
 	  wstr = wstr ? wcschr (wstr + 1, L':') : NULL;	/* end end */
-	  time->era_entries[idx].wname = (uint32_t *) wstr + 1;
 	  if (wstr != NULL)
 	    {
+	      time->era_entries[idx].wname = (uint32_t *) wstr + 1;
 	      wstr = wcschr (wstr + 1, L':');	/* end name */
-	      *wstr = L'\0';
-	      time->era_entries[idx].wformat = (uint32_t *) wstr + 1;
+	      if (wstr != NULL)
+		{
+		  *wstr = L'\0';
+		  time->era_entries[idx].wformat = (uint32_t *) wstr + 1;
+		}
+	      else
+		time->era_entries[idx].wname =
+		  time->era_entries[idx].wformat = (uint32_t *) L"";
 	    }
 	  else
-	    time->era_entries[idx].wformat = NULL;
+	    time->era_entries[idx].wname =
+	      time->era_entries[idx].wformat = (uint32_t *) L"";
 	}
     }
 

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]