[ros-diffs] [dchapyshev] 43055: - Add validation a computer name - Set limit for computer name length
dchapyshev at svn.reactos.org
dchapyshev at svn.reactos.org
Tue Sep 15 17:36:35 CEST 2009
Author: dchapyshev
Date: Tue Sep 15 17:36:35 2009
New Revision: 43055
URL: http://svn.reactos.org/svn/reactos?rev=43055&view=rev
Log:
- Add validation a computer name
- Set limit for computer name length
Modified:
trunk/reactos/dll/win32/netid/lang/bg-BG.rc
trunk/reactos/dll/win32/netid/lang/cs-CZ.rc
trunk/reactos/dll/win32/netid/lang/de-DE.rc
trunk/reactos/dll/win32/netid/lang/el-GR.rc
trunk/reactos/dll/win32/netid/lang/en-US.rc
trunk/reactos/dll/win32/netid/lang/es-ES.rc
trunk/reactos/dll/win32/netid/lang/fr-FR.rc
trunk/reactos/dll/win32/netid/lang/id-ID.rc
trunk/reactos/dll/win32/netid/lang/it-IT.rc
trunk/reactos/dll/win32/netid/lang/nl-NL.rc
trunk/reactos/dll/win32/netid/lang/no-NO.rc
trunk/reactos/dll/win32/netid/lang/pl-PL.rc
trunk/reactos/dll/win32/netid/lang/ru-RU.rc
trunk/reactos/dll/win32/netid/lang/sk-SK.rc
trunk/reactos/dll/win32/netid/lang/uk-UA.rc
trunk/reactos/dll/win32/netid/netid.c
Modified: trunk/reactos/dll/win32/netid/lang/bg-BG.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/bg-BG.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/bg-BG.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/bg-BG.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Çàáåëåæêà: Ñàìî óïðàâíèöèòå ìîãàò äà ïðîìåíÿò îïîçíàâàòåëèòå íà êîìïþòúðà."
1022 "Çàáåëåæêà: Îïîçíàâàòåëÿò íà êîìïþòúðà íå ìîæå äà áúäå ñìåíåí, çàùîòî:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Ïî&äðîáíîñòè >>"
3220 "<< &Ïî&äðîáíîñòè"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/cs-CZ.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/cs-CZ.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/cs-CZ.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/cs-CZ.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -76,6 +76,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Poznámka: Identifikaci tohoto poèítaèe mohou zmìnit pouze administrátoøi."
1022 "Poznámka: Identifikace poèítaèe nemùe být zmìnìna z následujících dùvodù:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Detaily >>"
3220 "<< &Detaily"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/de-DE.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/de-DE.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/de-DE.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/de-DE.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -78,6 +78,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Hinweis: Nur Administratoren können die Identifikation des Computers ändern."
1022 "Hinweis: Die Identifikation des Computers kann aus folgendem Grund nicht geändert werden:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Details >>"
3220 "<< &Details"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/el-GR.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/el-GR.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/el-GR.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/el-GR.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Note: Only Administrators can change the identification of this computer."
1022 "Note: The identification of the computer cannot be changed because:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Details >>"
3220 "<< &Details"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/en-US.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/en-US.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/en-US.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/en-US.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Note: Only Administrators can change the identification of this computer."
1022 "Note: The identification of the computer cannot be changed because:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Details >>"
3220 "<< &Details"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/es-ES.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/es-ES.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/es-ES.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/es-ES.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -75,6 +75,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Nota: Sólo los Administradores pueden cambiar la identificación de este equipo."
1022 "Nota: La identificación de este equipo no puede ser cambiada porque:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Detalles >>"
3220 "<< &Detalles"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/fr-FR.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/fr-FR.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/fr-FR.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/fr-FR.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Note : Seuls les administrateurs peuvent modifier l'identification de cet ordinateur."
1022 "Note : L'identification de l'ordinateur ne peut pas être modifiée car :"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Détails >>"
3220 "<< &Détails"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/id-ID.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/id-ID.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/id-ID.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/id-ID.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Note: Only Administrators can change the identification of this computer."
1022 "Note: The identification of the computer cannot be changed because:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Details >>"
3220 "<< &Details"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/it-IT.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/it-IT.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/it-IT.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/it-IT.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -71,6 +71,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Nota: Solo gli Amministratori possono cambiare l'identificazione di questo computer."
1022 "Nota: L'identificazione di questo computer non può essere cambiata perchè:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Dettagli >>"
3220 "<< &Dettagli"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/nl-NL.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/nl-NL.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/nl-NL.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/nl-NL.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Let op: Alleen Administrators mogen de indentificatie van deze computer aanpassen."
1022 "Let op: De indentificatie van deze computer kan niet gewijzigd worden omdat:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Details >>"
3220 "<< &Details"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/no-NO.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/no-NO.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/no-NO.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/no-NO.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "OBS: Bare administratorer kan endre identifisering for denne datamaskinen."
1022 "OBS: Identifisering for datamaskinen kunne ikke endres fordi:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Detaljer >>"
3220 "<< &Detaljer"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/pl-PL.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/pl-PL.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/pl-PL.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/pl-PL.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -78,6 +78,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Uwaga: Tylko Administratorzy mog¹ zmieniaæ identyfikator tego komputera."
1022 "Uwaga: Identyfikator tego komputera nie zosta³ zmieniony, powód:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Szczegó³y >>"
3220 "<< &Szczegó³y"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/ru-RU.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/ru-RU.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/ru-RU.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/ru-RU.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -70,6 +70,7 @@
25 "Ìîæíî èçìåíèòü èìÿ è ïðèíàäëåæíîñòü ýòîãî êîìïüþòåðà. Èçìåíåíèÿ ìîãóò ïîâëèÿòü íà äîñòóï ê ñåòåâûì ðåñóðñàì."
1021 "Ïðèìå÷àíèå: òîëüêî àäìèíèñòðàòîðû ìîãóò èçìåíèòü èäåíòèôèêàöèþ ýòîãî êîìïüþòåðà."
1022 "Ïðèìå÷àíèå: èäåíòèôèêàöèÿ ýòîãî êîìïüþòåðà íå ìîæåò áûòü èçìåíåíà, ïîòîìó ÷òî:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Ïîäðîáíî >>"
3220 "<< &Ïîäðîáíî"
4000 "Èíôîðìàöèÿ"
Modified: trunk/reactos/dll/win32/netid/lang/sk-SK.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/sk-SK.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/sk-SK.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/sk-SK.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -77,6 +77,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Poznámka: Iba správcovia môu zmeni identifikáciu tohto poèítaèa."
1022 "Poznámka: Identifikácia poèítaèa nemôe by zmenená, lebo:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Podrobnosti >>"
3220 "<< &Podrobnosti"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/lang/uk-UA.rc
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/lang/uk-UA.rc?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/lang/uk-UA.rc [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/lang/uk-UA.rc [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -78,6 +78,7 @@
25 "You can change the name and the membership of this computer. Changes may affect access to network resources."
1021 "Ïðèì³òêà: çì³íèòè ³äåíòèô³êàö³þ öüîãî êîìï'þòåðà ìîæóòü ëèøå àäì³í³ñòðàòîðè."
1022 "Ïðèì³òêà: çì³íèòè ³äåíòèô³êàö³þ öüîãî êîìï'þòåðà íåìîæëèâî, îñê³ëüêè:"
+ 1030 "The new computer name ""%s"" contains characters which are not allowed. Characters which are not allowed include ` ~ ! @ # $ %% ^ & * ( ) = + _ [ ] { } \\ | ; : ' \" , . < > / and ?"
3210 "&Ïîäðîáèö³ >>"
3220 "<< &Ïîäðîáèö³"
4000 "Information"
Modified: trunk/reactos/dll/win32/netid/netid.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/netid/netid.c?rev=43055&r1=43054&r2=43055&view=diff
==============================================================================
--- trunk/reactos/dll/win32/netid/netid.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/netid/netid.c [iso-8859-1] Tue Sep 15 17:36:35 2009
@@ -14,6 +14,12 @@
#include <prsht.h>
#include "resource.h"
+static INT_PTR CALLBACK
+NetIDPageProc(IN HWND hwndDlg,
+ IN UINT uMsg,
+ IN WPARAM wParam,
+ IN LPARAM lParam);
+
static HINSTANCE hDllInstance;
@@ -55,6 +61,28 @@
EnableWindow(GetDlgItem(hDlg, 1004), FALSE);
EnableWindow(GetDlgItem(hDlg, 116), FALSE);
EnableWindow(GetDlgItem(hDlg, 1007), FALSE);
+}
+
+static
+BOOL
+IsValidComputerName(LPCWSTR s)
+{
+ int i;
+
+ for (i = 0; i <= wcslen(s); i++)
+ {
+ if (s[i] == L'!' || s[i] == L'@' || s[i] == L'#' || s[i] == L'$'
+ || s[i] == L'^' || s[i] == L'&' || s[i] == L'\\' || s[i] == L'|'
+ || s[i] == L')' || s[i] == L'(' || s[i] == L'{' || s[i] == L'"'
+ || s[i] == L'}' || s[i] == L'~' || s[i] == L'/' || s[i] == L'\''
+ || s[i] == L'=' || s[i] == L':' || s[i] == L';' || s[i] == L'+'
+ || s[i] == L'<' || s[i] == L'>' || s[i] == L'?' || s[i] == L'['
+ || s[i] == L']' || s[i] == L'`' || s[i] == L'%' || s[i] == L'_'
+ || s[i] == L'.')
+ return FALSE;
+ }
+
+ return TRUE;
}
static
@@ -74,6 +102,8 @@
if (LoadString(hDllInstance, 25, MsgText, sizeof(MsgText) / sizeof(TCHAR)))
SetDlgItemText(hDlg, 1017, MsgText);
+
+ SendMessage(GetDlgItem(hDlg, 1002), EM_SETLIMITTEXT, MAX_COMPUTERNAME_LENGTH, 0);
if (GetComputerName(ComputerName, &Size))
{
@@ -143,6 +173,16 @@
{
switch (LOWORD(wParam))
{
+ case 1002:
+ if (HIWORD(wParam) == EN_CHANGE)
+ {
+ TCHAR szText[MAX_COMPUTERNAME_LENGTH + 1];
+
+ GetWindowText(GetDlgItem(hDlg, 1002), szText, MAX_COMPUTERNAME_LENGTH + 1);
+ SetDlgItemText(hDlg, 1001, szText);
+ }
+ break;
+
case 1008: /* Domain radio button */
case 1004: /* Workgroup radio button */
if (SendDlgItemMessage(hDlg, 1008, BM_GETCHECK, 0, 0) == BST_CHECKED)
@@ -172,13 +212,24 @@
{
if (_tcscmp(ComputerName, NewComputerName) != 0)
{
- if (!SetComputerName(NewComputerName))
+ if (!IsValidComputerName(NewComputerName))
+ {
+ TCHAR szText[MAX_PATH], szMsgText[MAX_PATH];
+
+ LoadString(hDllInstance, 1030, szText, sizeof(szText) / sizeof(TCHAR));
+
+ swprintf(szMsgText, szText, NewComputerName);
+ MessageBox(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
+ SetFocus(GetDlgItem(hDlg, 1002));
+ break;
+ }
+ else if (!SetComputerName(NewComputerName))
{
TCHAR szMsgText[MAX_PATH];
LoadString(hDllInstance, 4001, szMsgText, sizeof(szMsgText) / sizeof(TCHAR));
- MessageBox(0, szMsgText, NULL, MB_OK | MB_ICONERROR);
+ MessageBox(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
}
else
{
@@ -188,6 +239,8 @@
LoadString(hDllInstance, 24, szMsgText, sizeof(szMsgText) / sizeof(TCHAR));
MessageBox(hDlg, szMsgText, szMsgTitle, MB_OK | MB_ICONINFORMATION);
+
+ NetIDPageProc(GetParent(hDlg), WM_INITDIALOG, 0, 0);
}
}
}
More information about the Ros-diffs
mailing list