diff options
| author | Daniel Colascione | 2014-03-21 20:04:53 -0700 |
|---|---|---|
| committer | Daniel Colascione | 2014-03-21 20:04:53 -0700 |
| commit | 43c75c8eae588a358af95c942742213040240b67 (patch) | |
| tree | 7bd5b80695e28b2bf1a84dfe1de19d9353aba6d3 /src | |
| parent | 8266cd885b38e8f03187ab0886d49d5976bd7b35 (diff) | |
| parent | ea64063f079e31f824de1f471074c69281fb06fd (diff) | |
| download | emacs-43c75c8eae588a358af95c942742213040240b67.tar.gz emacs-43c75c8eae588a358af95c942742213040240b67.zip | |
Do not read uninitialized memory in conv_sockaddr_to_lisp
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/process.c | 20 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 59e39614af8..94b48f64de3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-03-22 Daniel Colascione <dancol@dancol.org> | ||
| 2 | |||
| 3 | * process.c (conv_sockaddr_to_lisp): When extracting the string | ||
| 4 | names of AF_LOCAL sockets, stop before reading uninitialized | ||
| 5 | memory. | ||
| 6 | |||
| 1 | 2014-03-21 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> | 7 | 2014-03-21 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp> |
| 2 | 8 | ||
| 3 | Fix regression introduced by patch for Bug#10500. | 9 | Fix regression introduced by patch for Bug#10500. |
diff --git a/src/process.c b/src/process.c index 187627dd85a..10a2984a053 100644 --- a/src/process.c +++ b/src/process.c | |||
| @@ -2010,10 +2010,22 @@ conv_sockaddr_to_lisp (struct sockaddr *sa, int len) | |||
| 2010 | case AF_LOCAL: | 2010 | case AF_LOCAL: |
| 2011 | { | 2011 | { |
| 2012 | struct sockaddr_un *sockun = (struct sockaddr_un *) sa; | 2012 | struct sockaddr_un *sockun = (struct sockaddr_un *) sa; |
| 2013 | for (i = 0; i < sizeof (sockun->sun_path); i++) | 2013 | ptrdiff_t name_length = len - offsetof (struct sockaddr_un, sun_path); |
| 2014 | if (sockun->sun_path[i] == 0) | 2014 | /* If the first byte is NUL, the name is a Linux abstract |
| 2015 | break; | 2015 | socket name, and the name can contain embedded NULs. If |
| 2016 | return make_unibyte_string (sockun->sun_path, i); | 2016 | it's not, we have a NUL-terminated string. Be careful not |
| 2017 | to walk past the end of the object looking for the name | ||
| 2018 | terminator, however. */ | ||
| 2019 | if (name_length > 0 && sockun->sun_path[0] != '\0') | ||
| 2020 | { | ||
| 2021 | const char* terminator = | ||
| 2022 | memchr (sockun->sun_path, '\0', name_length); | ||
| 2023 | |||
| 2024 | if (terminator) | ||
| 2025 | name_length = terminator - (const char*) sockun->sun_path; | ||
| 2026 | } | ||
| 2027 | |||
| 2028 | return make_unibyte_string (sockun->sun_path, name_length); | ||
| 2017 | } | 2029 | } |
| 2018 | #endif | 2030 | #endif |
| 2019 | default: | 2031 | default: |