Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame^] | 1 | ppp: Buffer overflow in radius plugin |
| 2 | |
| 3 | From: https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;bug=782450 |
| 4 | |
| 5 | Upstream-Status: Backport |
| 6 | |
| 7 | On systems with more than 65535 processes running, pppd aborts when |
| 8 | sending a "start" accounting message to the RADIUS server because of a |
| 9 | buffer overflow in rc_mksid. |
| 10 | |
| 11 | The process id is used in rc_mksid to generate a pseudo-unique string, |
| 12 | assuming that the hex representation of the pid will be at most 4 |
| 13 | characters (FFFF). __sprintf_chk(), used when compiling with |
| 14 | optimization levels greater than 0 and FORTIFY_SOURCE, detects the |
| 15 | buffer overflow and makes pppd crash. |
| 16 | |
| 17 | The following patch fixes the problem. |
| 18 | |
| 19 | --- ppp-2.4.6.orig/pppd/plugins/radius/util.c |
| 20 | +++ ppp-2.4.6/pppd/plugins/radius/util.c |
| 21 | @@ -77,7 +77,7 @@ rc_mksid (void) |
| 22 | static unsigned short int cnt = 0; |
| 23 | sprintf (buf, "%08lX%04X%02hX", |
| 24 | (unsigned long int) time (NULL), |
| 25 | - (unsigned int) getpid (), |
| 26 | + (unsigned int) getpid () % 65535, |
| 27 | cnt & 0xFF); |
| 28 | cnt++; |
| 29 | return buf; |