| 1 | Ticket: https://trac.macports.org/ticket/41077 |
| 2 | Upstream: https://issues.apache.org/bugzilla/show_bug.cgi?id=55696 |
| 3 | Note: Upstream patch modified, s/strncpy/strlcpy/ |
| 4 | |
| 5 | Index: common/jk_map.c |
| 6 | =================================================================== |
| 7 | --- common/jk_map.c (revision 1535519) |
| 8 | +++ common/jk_map.c (working copy) |
| 9 | @@ -183,33 +183,37 @@ |
| 10 | |
| 11 | int jk_map_get_int(jk_map_t *m, const char *name, int def) |
| 12 | { |
| 13 | - char buf[100]; |
| 14 | const char *rc; |
| 15 | - size_t len; |
| 16 | int int_res; |
| 17 | - int multit = 1; |
| 18 | |
| 19 | - sprintf(buf, "%d", def); |
| 20 | - rc = jk_map_get_string(m, name, buf); |
| 21 | + rc = jk_map_get_string(m, name, NULL); |
| 22 | |
| 23 | - len = strlen(rc); |
| 24 | - if (len) { |
| 25 | - char *lastchar = &buf[0] + len - 1; |
| 26 | - strcpy(buf, rc); |
| 27 | - if ('m' == *lastchar || 'M' == *lastchar) { |
| 28 | - *lastchar = '\0'; |
| 29 | - multit = 1024 * 1024; |
| 30 | + if(NULL == rc) { |
| 31 | + int_res = def; |
| 32 | + } else { |
| 33 | + size_t len = strlen(rc); |
| 34 | + int multit = 1; |
| 35 | + |
| 36 | + if (len) { |
| 37 | + char buf[100]; |
| 38 | + char *lastchar; |
| 39 | + strlcpy(buf, rc, 100); |
| 40 | + lastchar = buf + len - 1; |
| 41 | + if ('m' == *lastchar || 'M' == *lastchar) { |
| 42 | + *lastchar = '\0'; |
| 43 | + multit = 1024 * 1024; |
| 44 | + } |
| 45 | + else if ('k' == *lastchar || 'K' == *lastchar) { |
| 46 | + *lastchar = '\0'; |
| 47 | + multit = 1024; |
| 48 | + } |
| 49 | + int_res = multit * atoi(buf); |
| 50 | } |
| 51 | - else if ('k' == *lastchar || 'K' == *lastchar) { |
| 52 | - *lastchar = '\0'; |
| 53 | - multit = 1024; |
| 54 | - } |
| 55 | - int_res = atoi(buf); |
| 56 | + else |
| 57 | + int_res = def; |
| 58 | } |
| 59 | - else |
| 60 | - int_res = def; |
| 61 | |
| 62 | - return int_res * multit; |
| 63 | + return int_res; |
| 64 | } |
| 65 | |
| 66 | double jk_map_get_double(jk_map_t *m, const char *name, double def) |