Browse Source

handle ENAMETOOLONG in various places

- ENAMETOOLONG:
  - static, flv: return 414
  - dirlist, pathinfo: treat as not-existing (i.e. no handling)
- also return 500 instead of closing the connection when stat/open
  fails an unhandled error
- explicit return instead of switch-case fallthrough (no semantic
  change) in actions.c

Change-Id: I1e2dd721dd18544500b4436ada843cb6e7f2db72
master
Stefan Bühler 3 years ago
parent
commit
808cdf301b
4 changed files with 21 additions and 6 deletions
  1. +3
    -0
      src/main/actions.c
  2. +9
    -3
      src/main/plugin_core.c
  3. +4
    -2
      src/modules/mod_dirlist.c
  4. +5
    -1
      src/modules/mod_flv.c

+ 3
- 0
src/main/actions.c View File

@@ -320,6 +320,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
break;
case LI_HANDLER_ERROR:
li_action_stack_reset(vr, as);
return res;
case LI_HANDLER_COMEBACK:
case LI_HANDLER_WAIT_FOR_EVENT:
return res;
@@ -395,6 +396,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
break;
case LI_HANDLER_ERROR:
li_action_stack_reset(vr, as);
return res;
case LI_HANDLER_COMEBACK:
case LI_HANDLER_WAIT_FOR_EVENT:
return res;
@@ -422,6 +424,7 @@ liHandlerResult li_action_execute(liVRequest *vr) {
break;
case LI_HANDLER_ERROR:
li_action_stack_reset(vr, as);
return res;
case LI_HANDLER_COMEBACK:
case LI_HANDLER_WAIT_FOR_EVENT:
return res;


+ 9
- 3
src/main/plugin_core.c View File

@@ -625,9 +625,13 @@ static liHandlerResult core_handle_static(liVRequest *vr, gpointer param, gpoint
case EACCES:
vr->response.http_status = 403;
return LI_HANDLER_GO_ON;
case ENAMETOOLONG:
vr->response.http_status = 414;
return LI_HANDLER_GO_ON;
default:
VR_ERROR(vr, "stat() or open() for '%s' failed: %s", vr->physical.path->str, g_strerror(err));
return LI_HANDLER_ERROR;
vr->response.http_status = 500;
return LI_HANDLER_GO_ON;
}
} else if (S_ISDIR(st.st_mode)) {
if (fd != -1)
@@ -815,13 +819,15 @@ next_round:
VR_DEBUG(vr, "physical path: %s", vr->physical.path->str);
}
goto next_round;
case ENAMETOOLONG:
case ENOENT:
return LI_HANDLER_GO_ON;
case EACCES:
return LI_HANDLER_GO_ON;
default:
VR_ERROR(vr, "stat() or open() for '%s' failed: %s", vr->physical.path->str, g_strerror(err));
return LI_HANDLER_ERROR;
if (!li_vrequest_handle_direct(vr)) return LI_HANDLER_ERROR;
vr->response.http_status = 500;
return LI_HANDLER_GO_ON;
}

return LI_HANDLER_GO_ON;


+ 4
- 2
src/modules/mod_dirlist.c View File

@@ -329,14 +329,16 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context
switch (e) {
case ENOENT:
case ENOTDIR:
case ENAMETOOLONG:
return LI_HANDLER_GO_ON;
case EACCES:
if (!li_vrequest_handle_direct(vr)) return LI_HANDLER_ERROR;
vr->response.http_status = 403;
return LI_HANDLER_GO_ON;
default:
VR_ERROR(vr, "stat('%s') failed: %s", sce->data.path->str, g_strerror(sce->data.err));
return LI_HANDLER_ERROR;
if (!li_vrequest_handle_direct(vr)) return LI_HANDLER_ERROR;
vr->response.http_status = 500;
return LI_HANDLER_GO_ON;
}
} else if (!S_ISDIR(sce->data.st.st_mode)) {
li_stat_cache_entry_release(vr, sce);


+ 5
- 1
src/modules/mod_flv.c View File

@@ -54,9 +54,13 @@ static liHandlerResult flv(liVRequest *vr, gpointer param, gpointer *context) {
case EACCES:
vr->response.http_status = 403;
return LI_HANDLER_GO_ON;
case ENAMETOOLONG:
vr->response.http_status = 414;
return LI_HANDLER_GO_ON;
default:
VR_ERROR(vr, "stat() or open() for '%s' failed: %s", vr->physical.path->str, g_strerror(err));
return LI_HANDLER_ERROR;
vr->response.http_status = 500;
return LI_HANDLER_GO_ON;
}
} else if (S_ISDIR(st.st_mode)) {
if (fd != -1)


Loading…
Cancel
Save