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


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 kernel version parsing when it has more than 3 components


with kernel versions having more than 3 components being common place, a bug 
was noticed in _dl_discover_osversion() where it would parse all parts of the 
kernel version rather than just consuming the first 3.  for example, the 
function would return incorrect values when running on "2.6.21.5" but would 
work properly on "2.6.21".  the attached patch fixes this by bailing out 
after processing the first three components.
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

2007-07-07  Mike Frysinger  <vapier@gentoo.org>

	* sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_discover_osversion): Break
	after reading the first 3 parts of the kernel version.

--- libc/sysdeps/unix/sysv/linux/dl-osinfo.h
+++ libc/sysdeps/unix/sysv/linux/dl-osinfo.h
@@ -112,7 +112,7 @@ _dl_discover_osversion (void)
   version = 0;
   parts = 0;
   cp = buf;
-  while ((*cp >= '0') && (*cp <= '9'))
+  while ((*cp >= '0') && (*cp <= '9') && parts < 3)
     {
       unsigned int here = *cp++ - '0';
 

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