Преглед изворни кода

The gethostname fix

svn path=/trunk/mcs/; revision=15034
Miguel de Icaza пре 22 година
родитељ
комит
89902bf34a

+ 4 - 0
mcs/class/System.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,3 +1,7 @@
+2003-04-25  Miguel de Icaza  <[email protected]>
+
+        * SystemInformation.cs (ComputerName): Bug fix: we need to trim down the size
+
 2003-05-30  Aleksey Ryabchuk <[email protected]>
 	* GroupBox.cs : take BackColor into account
 

+ 6 - 1
mcs/class/System.Windows.Forms/System.Windows.Forms/SystemInformation.cs

@@ -66,12 +66,17 @@ namespace System.Windows.Forms {
 		static string _gethostname ()
 		{
 			byte [] buf = new byte [256];
+			int count;
 			unsafe {
 				fixed (byte *p = &buf [0]){
+					byte *q = p;
 					gethostname (p, 256);
+					while (*q != 0 && ((int)(p-q) < 256))
+						q++;
+					count = (int) (q - p);
 				}
 			}
-			return new String(Encoding.UTF8.GetChars (buf));
+			return new String(Encoding.UTF8.GetChars (buf, 0, count));
 		}
 	
 		public static string ComputerName {