[Remove entries to the current 2.0 section below, when backported]
+ *) Improve error handling for corrupted pid files. [Jeff Trawick]
+
*) mod_proxy.c and proxy_util.c: Enable compiling on 2.0-HEAD
(for backwards compatibility):
Avoids mod_ssl.h (not included in 2.0-HEAD) and
return rv;
}
- /* Ensure null-termination, so that strtol doesn't go crazy. */
buf = apr_palloc(p, BUFFER_SIZE);
- buf[BUFFER_SIZE - 1] = '\0';
rv = apr_file_read_full(pid_file, buf, BUFFER_SIZE - 1, &bytes_read);
if (rv != APR_SUCCESS && rv != APR_EOF) {
/* If we fill the buffer, we're probably reading a corrupt pid file.
* To be nice, let's also ensure the first char is a digit. */
- if (bytes_read == BUFFER_SIZE - 1 || !apr_isdigit(*buf)) {
+ if (bytes_read == 0 || bytes_read == BUFFER_SIZE - 1 || !apr_isdigit(*buf)) {
return APR_EGENERAL;
}
+ buf[bytes_read] = '\0';
*mypid = strtol(buf, &endptr, 10);
apr_file_close(pid_file);
if (rv != APR_ENOENT) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, rv, NULL,
"Error retrieving pid file %s", ap_pid_fname);
+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
+ "Remove it before continuing if it is corrupted.");
*exit_status = 1;
return 1;
}