From 868ee46fc9108e42b8bbf154a7aea4df4b9d5f93 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Wed, 19 Feb 2014 12:43:58 +0000 Subject: [PATCH] Merge r1487528, r1563379, r1563381, r1565711 from trunk: * server/protocol.c (r_flush): Use int return type as per declaration of apr_vformatter(); no functional change. Use %pm in order to save 8k of stack in 'ap_pcfg_strerror' s/apr_pstrndup/apr_pstrmemdup/ when applicable follow-up to r1096569: remove unnecessary total_modules calculation Submitted by: jorton, jailletc36, jailletc36, trawick Reviewed/backported by: jim git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1569726 13f79535-47bb-0310-9956-ffa450edef68 --- STATUS | 13 ------------- modules/cache/cache_storage.c | 2 +- modules/generators/mod_cgid.c | 5 ----- server/protocol.c | 5 +++-- server/util.c | 20 ++++++++++---------- 5 files changed, 14 insertions(+), 31 deletions(-) diff --git a/STATUS b/STATUS index ef4d2d76f8..d3d1091b7f 100644 --- a/STATUS +++ b/STATUS @@ -98,19 +98,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * Easy proposals to synch 2.4 and trunk - - server/protocol.c (r_flush): Use int return type as per declaration - of apr_vformatter(); no functional change. - - core: Use %pm in order to save 8k of stack in 'ap_pcfg_strerror' - - core & cache: s/apr_pstrndup/apr_pstrmemdup/ when applicable - - mod_cgid: remove unnecessary total_modules calculation (follow-up to r1096569) - trunk patch: http://svn.apache.org/r1487528 - http://svn.apache.org/r1563379 - http://svn.apache.org/r1563381 - http://svn.apache.org/r1565711 - 2.4.x patch: trunk patches work - +1: jailletc36, covener, jim - PATCHES PROPOSED TO BACKPORT FROM TRUNK: diff --git a/modules/cache/cache_storage.c b/modules/cache/cache_storage.c index 782dc712fc..234eb9bb74 100644 --- a/modules/cache/cache_storage.c +++ b/modules/cache/cache_storage.c @@ -582,7 +582,7 @@ static apr_status_t cache_canonicalise_key(request_rec *r, apr_pool_t* p, && !strncmp(param + 1, *identifier, len) && (*(param + len + 1) == '=') && !ap_strchr_c(param + len + 2, '/')) { - path = apr_pstrndup(p, path, param - path); + path = apr_pstrmemdup(p, path, param - path); continue; } /* diff --git a/modules/generators/mod_cgid.c b/modules/generators/mod_cgid.c index 56d3524330..499e37dc6f 100644 --- a/modules/generators/mod_cgid.c +++ b/modules/generators/mod_cgid.c @@ -87,7 +87,6 @@ static APR_OPTIONAL_FN_TYPE(ap_ssi_get_tag_and_value) *cgid_pfn_gtv; static APR_OPTIONAL_FN_TYPE(ap_ssi_parse_string) *cgid_pfn_ps; static apr_pool_t *pcgi = NULL; -static int total_modules = 0; static pid_t daemon_pid; static int daemon_should_exit = 0; static server_rec *root_server = NULL; @@ -896,7 +895,6 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, { apr_proc_t *procnew = NULL; const char *userdata_key = "cgid_init"; - module **m; int ret = OK; void *data; @@ -918,9 +916,6 @@ static int cgid_init(apr_pool_t *p, apr_pool_t *plog, apr_pool_t *ptemp, if (ap_state_query(AP_SQ_MAIN_STATE) != AP_SQ_MS_CREATE_PRE_CONFIG) { char *tmp_sockname; - total_modules = 0; - for (m = ap_preloaded_modules; *m != NULL; m++) - total_modules++; parent_pid = getpid(); tmp_sockname = ap_runtime_dir_relative(p, sockname); diff --git a/server/protocol.c b/server/protocol.c index a0b3246427..341fe32b19 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -1557,7 +1557,8 @@ struct ap_vrprintf_data { char *buff; }; -static apr_status_t r_flush(apr_vformatter_buff_t *buff) +/* Flush callback for apr_vformatter; returns -1 on error. */ +static int r_flush(apr_vformatter_buff_t *buff) { /* callback function passed to ap_vformatter to be called when * vformatter needs to write into buff and buff.curpos > buff.endpos */ @@ -1578,7 +1579,7 @@ static apr_status_t r_flush(apr_vformatter_buff_t *buff) vd->vbuff.curpos = vd->buff; vd->vbuff.endpos = vd->buff + AP_IOBUFSIZE; - return APR_SUCCESS; + return 0; } AP_DECLARE(int) ap_vrprintf(request_rec *r, const char *fmt, va_list va) diff --git a/server/util.c b/server/util.c index e0ba5c28a3..2b6030005c 100644 --- a/server/util.c +++ b/server/util.c @@ -115,7 +115,7 @@ AP_DECLARE(char *) ap_field_noparam(apr_pool_t *p, const char *intype) while ((semi > intype) && apr_isspace(semi[-1])) { semi--; } - return apr_pstrndup(p, intype, semi - intype); + return apr_pstrmemdup(p, intype, semi - intype); } } @@ -736,7 +736,7 @@ AP_DECLARE(char *) ap_getword_nulls(apr_pool_t *atrans, const char **line, return res; } - res = apr_pstrndup(atrans, *line, pos - *line); + res = apr_pstrmemdup(atrans, *line, pos - *line); ++pos; @@ -956,13 +956,15 @@ AP_DECLARE(apr_status_t) ap_cfg_getc(char *ch, ap_configfile_t *cfp) AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp, apr_status_t rc) { - char buf[MAX_STRING_LEN]; if (rc == APR_SUCCESS) return NULL; - return apr_psprintf(p, "Error reading %s at line %d: %s", - cfp->name, cfp->line_number, - rc == APR_ENOSPC ? "Line too long" - : apr_strerror(rc, buf, sizeof(buf))); + + if (rc == APR_ENOSPC) + return apr_psprintf(p, "Error reading %s at line %d: Line too long", + cfp->name, cfp->line_number); + + return apr_psprintf(p, "Error reading %s at line %d: %pm", + cfp->name, cfp->line_number, &rc); } /* Read one line from open ap_configfile_t, strip LF, increase line number */ @@ -1461,7 +1463,6 @@ AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, const char *ptr = *accept_line; const char *tok_start; char *token; - int tok_len; /* Find first non-white byte */ @@ -1482,8 +1483,7 @@ AP_DECLARE(char *) ap_get_token(apr_pool_t *p, const char **accept_line, break; } - tok_len = ptr - tok_start; - token = apr_pstrndup(p, tok_start, tok_len); + token = apr_pstrmemdup(p, tok_start, ptr - tok_start); /* Advance accept_line pointer to the next non-white byte */ -- 2.50.1