stas Sat Feb 17 01:47:26 2007 UTC
Modified files:
/php-src/ext/pspell pspell.c
Log:
use safer functions, check error value
http://cvs.php.net/viewvc.cgi/php-src/ext/pspell/pspell.c?r1=1.56&r2=1.57&diff_format=u
Index: php-src/ext/pspell/pspell.c
diff -u php-src/ext/pspell/pspell.c:1.56 php-src/ext/pspell/pspell.c:1.57
--- php-src/ext/pspell/pspell.c:1.56 Tue Jan 16 11:18:54 2007
+++ php-src/ext/pspell/pspell.c Sat Feb 17 01:47:26 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: pspell.c,v 1.56 2007/01/16 11:18:54 tony2001 Exp $ */
+/* $Id: pspell.c,v 1.57 2007/02/17 01:47:26 stas Exp $ */
#define IS_EXT_MODULE
@@ -186,16 +186,19 @@
* pointing to the location of the dictionaries
*/
if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
+ LONG result;
dwLen = sizeof(aspell_dir) - 1;
- RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir,
&dwLen);
+ result = RegQueryValueEx(hkey, "", NULL, &dwType,
(LPBYTE)&aspell_dir, &dwLen);
RegCloseKey(hkey);
- strcpy(data_dir, aspell_dir);
- strcat(data_dir, "\\data");
- strcpy(dict_dir, aspell_dir);
- strcat(dict_dir, "\\dict");
+ if(result == ERROR_SUCCESS) {
+ strlcpy(data_dir, aspell_dir, sizeof(data_dir));
+ strlcat(data_dir, "\\data", sizeof(data_dir));
+ strlcpy(dict_dir, aspell_dir, sizeof(dict_dir));
+ strlcat(dict_dir, "\\dict", sizeof(dict_dir));
- pspell_config_replace(config, "data-dir", data_dir);
- pspell_config_replace(config, "dict-dir", dict_dir);
+ pspell_config_replace(config, "data-dir", data_dir);
+ pspell_config_replace(config, "dict-dir", dict_dir);
+ }
}
#endif
@@ -291,16 +294,19 @@
* pointing to the location of the dictionaries
*/
if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
+ LONG result;
dwLen = sizeof(aspell_dir) - 1;
- RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir,
&dwLen);
+ result = RegQueryValueEx(hkey, "", NULL, &dwType,
(LPBYTE)&aspell_dir, &dwLen);
RegCloseKey(hkey);
- strcpy(data_dir, aspell_dir);
- strcat(data_dir, "\\data");
- strcpy(dict_dir, aspell_dir);
- strcat(dict_dir, "\\dict");
+ if(result == ERROR_SUCCESS) {
+ strlcpy(data_dir, aspell_dir, sizeof(data_dir));
+ strlcat(data_dir, "\\data", sizeof(data_dir));
+ strlcpy(dict_dir, aspell_dir, sizeof(dict_dir));
+ strlcat(dict_dir, "\\dict", sizeof(dict_dir));
- pspell_config_replace(config, "data-dir", data_dir);
- pspell_config_replace(config, "dict-dir", dict_dir);
+ pspell_config_replace(config, "data-dir", data_dir);
+ pspell_config_replace(config, "dict-dir", dict_dir);
+ }
}
#endif
@@ -644,16 +650,19 @@
* pointing to the location of the dictionaries
*/
if(0 == RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Aspell", &hkey)) {
+ LONG result;
dwLen = sizeof(aspell_dir) - 1;
- RegQueryValueEx(hkey, "", NULL, &dwType, (LPBYTE)&aspell_dir,
&dwLen);
+ result = RegQueryValueEx(hkey, "", NULL, &dwType,
(LPBYTE)&aspell_dir, &dwLen);
RegCloseKey(hkey);
- strcpy(data_dir, aspell_dir);
- strcat(data_dir, "\\data");
- strcpy(dict_dir, aspell_dir);
- strcat(dict_dir, "\\dict");
+ if(result == ERROR_SUCCESS) {
+ strlcpy(data_dir, aspell_dir, sizeof(data_dir));
+ strlcat(data_dir, "\\data", sizeof(data_dir));
+ strlcpy(dict_dir, aspell_dir, sizeof(dict_dir));
+ strlcat(dict_dir, "\\dict", sizeof(dict_dir));
- pspell_config_replace(config, "data-dir", data_dir);
- pspell_config_replace(config, "dict-dir", dict_dir);
+ pspell_config_replace(config, "data-dir", data_dir);
+ pspell_config_replace(config, "dict-dir", dict_dir);
+ }
}
#endif
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php