Skip to content

Fix view server crash when map/reduce function throws null#5944

Open
vamsi2246 wants to merge 1 commit intoapache:mainfrom
vamsi2246:fix-null-crash-view-server
Open

Fix view server crash when map/reduce function throws null#5944
vamsi2246 wants to merge 1 commit intoapache:mainfrom
vamsi2246:fix-null-crash-view-server

Conversation

@vamsi2246
Copy link

Overview

This PR fixes a critical bug where the JavaScript view server crashes if a user-defined map or reduce function throws null or undefined.

Details

When a map function executes throw null;, the resulting error caught by views.js is null. The handleViewError function attempts to check if (err[0] == "fatal"), which immediately throws a TypeError: Cannot read properties of null (reading '0'). Because this occurs inside the uncaught error handler, it crashes the entire couchjs OS process, failing the view query completely.

The same vulnerability exists inside errstr (util.js) which unsafely checks e.toSource.

This patch adds safe null checks to these critical property accesses, allowing the view server to correctly log the null exception and proceed without crashing.

When a map or reduce function throws null or undefined, the
JavaScript view server's error handlers crash while attempting
to stringify or access properties on the null exception.
This patch adds safe null checks to these critical property
accesses, allowing the view server to correctly log the
exception and proceed without crashing the entire OS process.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant