Don't put RTSP URL passwords into the log

When logging, use cnt->conf.netcam_url instead of rtsp->path, as the
latter may contain a security-sensitive "user:password@" string. We add
a new rtsp->netcam_url field that is a read-only pointer to the former.

Also, don't try to LOG("%s", NULL).
This commit is contained in:
Daniel Richard G
2017-04-10 17:12:02 -04:00
parent 1b6022f595
commit 3b75bec4fa
2 changed files with 11 additions and 4 deletions

View File

@@ -282,7 +282,7 @@ static int netcam_interrupt_rtsp(void *ctx){
MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time failed");
}
if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 10){
MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Camera timed out for %s",rtsp->path);
MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Camera timed out for %s", rtsp->netcam_url);
rtsp->interrupted = 1;
return 1;
} else{
@@ -299,7 +299,7 @@ static int netcam_interrupt_rtsp(void *ctx){
MOTION_LOG(WRN, TYPE_NETCAM, SHOW_ERRNO, "%s: get interrupt time failed");
}
if ((interrupttime.tv_sec - rtsp->startreadtime.tv_sec ) > 30){
MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Camera timed out for %s",rtsp->path);
MOTION_LOG(WRN, TYPE_NETCAM, NO_ERRNO, "%s: Camera timed out for %s", rtsp->netcam_url);
rtsp->interrupted = 1;
return 1;
} else{
@@ -464,7 +464,7 @@ static int netcam_rtsp_open_context(netcam_context_ptr netcam){
if (netcam->rtsp->path == NULL) {
if (netcam->rtsp->status == RTSP_NOTCONNECTED){
MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect (%s)", netcam->rtsp->path);
MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: Null path passed to connect");
}
return -1;
}
@@ -523,7 +523,7 @@ static int netcam_rtsp_open_context(netcam_context_ptr netcam){
if ((retcd < 0) || (netcam->rtsp->interrupted == 1)){
if (netcam->rtsp->status == RTSP_NOTCONNECTED){
av_strerror(retcd, errstr, sizeof(errstr));
MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->path,errstr);
MOTION_LOG(ERR, TYPE_NETCAM, NO_ERRNO, "%s: unable to open input(%s): %s", netcam->rtsp->netcam_url, errstr);
}
av_dict_free(&opts);
//The format context gets freed upon any error from open_input.
@@ -941,6 +941,12 @@ int netcam_setup_rtsp(netcam_context_ptr netcam, struct url_t *url){
netcam_url_free(url);
/*
* Keep a pointer to the original URL for logging purposes
* (we don't want to put passwords into the log)
*/
netcam->rtsp->netcam_url = cnt->conf.netcam_url;
/*
* Now we need to set some flags
*/

View File

@@ -23,6 +23,7 @@ struct rtsp_context {
char* path;
char* user;
char* pass;
const char* netcam_url;
int interrupted;
enum RTSP_STATUS status;
struct timeval startreadtime;