diff options
| author | Juanma Barranquero | 2010-09-22 19:31:21 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2010-09-22 19:31:21 +0200 |
| commit | 38c54d9dabb8e699b9e42854517e6493fbefa191 (patch) | |
| tree | fb4565942bfa3881e47ba3bd1eb78850e0d3a802 /src | |
| parent | 8f978ca0d54104c3da1bd34e0a45e0aeedcd7a69 (diff) | |
| download | emacs-38c54d9dabb8e699b9e42854517e6493fbefa191.tar.gz emacs-38c54d9dabb8e699b9e42854517e6493fbefa191.zip | |
src/w32.c (get_emacs_configuration_options): Fix buffer overrun.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/w32.c | 43 |
2 files changed, 35 insertions, 13 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 6bb13eaa088..4d8add512a4 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2010-09-22 Juanma Barranquero <lekktu@gmail.com> | ||
| 2 | Eli Zaretskii <eliz@gnu.org> | ||
| 3 | |||
| 4 | * w32.c (get_emacs_configuration_options): Fix buffer overrun. | ||
| 5 | |||
| 1 | 2010-09-22 Eli Zaretskii <eliz@gnu.org> | 6 | 2010-09-22 Eli Zaretskii <eliz@gnu.org> |
| 2 | 7 | ||
| 3 | * minibuf.c (Fminibuffer_contents) | 8 | * minibuf.c (Fminibuffer_contents) |
| @@ -1925,7 +1925,25 @@ get_emacs_configuration (void) | |||
| 1925 | char * | 1925 | char * |
| 1926 | get_emacs_configuration_options (void) | 1926 | get_emacs_configuration_options (void) |
| 1927 | { | 1927 | { |
| 1928 | static char options_buffer[256]; | 1928 | static char *options_buffer; |
| 1929 | char cv[32]; /* Enough for COMPILER_VERSION. */ | ||
| 1930 | char *options[] = { | ||
| 1931 | cv, /* To be filled later. */ | ||
| 1932 | #ifdef EMACSDEBUG | ||
| 1933 | " --no-opt", | ||
| 1934 | #endif | ||
| 1935 | /* configure.bat already sets USER_CFLAGS and USER_LDFLAGS | ||
| 1936 | with a starting space to save work here. */ | ||
| 1937 | #ifdef USER_CFLAGS | ||
| 1938 | " --cflags", USER_CFLAGS, | ||
| 1939 | #endif | ||
| 1940 | #ifdef USER_LDFLAGS | ||
| 1941 | " --ldflags", USER_LDFLAGS, | ||
| 1942 | #endif | ||
| 1943 | NULL | ||
| 1944 | }; | ||
| 1945 | size_t size = 0; | ||
| 1946 | int i; | ||
| 1929 | 1947 | ||
| 1930 | /* Work out the effective configure options for this build. */ | 1948 | /* Work out the effective configure options for this build. */ |
| 1931 | #ifdef _MSC_VER | 1949 | #ifdef _MSC_VER |
| @@ -1938,18 +1956,17 @@ get_emacs_configuration_options (void) | |||
| 1938 | #endif | 1956 | #endif |
| 1939 | #endif | 1957 | #endif |
| 1940 | 1958 | ||
| 1941 | sprintf (options_buffer, COMPILER_VERSION); | 1959 | if (_snprintf (cv, sizeof (cv), COMPILER_VERSION) < 0) |
| 1942 | #ifdef EMACSDEBUG | 1960 | return "Error: not enough space for compiler version"; |
| 1943 | strcat (options_buffer, " --no-opt"); | 1961 | |
| 1944 | #endif | 1962 | for (i = 0; options[i]; i++) |
| 1945 | #ifdef USER_CFLAGS | 1963 | size += strlen (options[i]); |
| 1946 | strcat (options_buffer, " --cflags"); | 1964 | |
| 1947 | strcat (options_buffer, USER_CFLAGS); | 1965 | options_buffer = xmalloc (size + 1); |
| 1948 | #endif | 1966 | |
| 1949 | #ifdef USER_LDFLAGS | 1967 | for (i = 0; options[i]; i++) |
| 1950 | strcat (options_buffer, " --ldflags"); | 1968 | strcat (options_buffer, options[i]); |
| 1951 | strcat (options_buffer, USER_LDFLAGS); | 1969 | |
| 1952 | #endif | ||
| 1953 | return options_buffer; | 1970 | return options_buffer; |
| 1954 | } | 1971 | } |
| 1955 | 1972 | ||