Uh oh!
There was an error while loading. Please reload this page.
fs: do basic arg validation of truncate in js - #2498
Conversation
mscdex
commented
Aug 22, 2015
Out of curiousity, what was the motivation behind these changes? |
b93d681 to
9910ba2Comparethefourtheye
commented
Aug 22, 2015
There was a problem hiding this comment.
Just seeing the error message. If you want to ensure it is an integer, you can drop Number.isFinite and use Number.isInteger instead
There was a problem hiding this comment.
@targos Man, that's wonderful. I didn't know about that function and that is exactly what we need here. Thanks :-) Updated the PR.
thefourtheye
commented
Aug 27, 2015
@bnoordhuis Ping! |
There was a problem hiding this comment.
Change in functionality. Here's an approximate test:
if(typeofpath==='number'&&!Number.isInteger(path))thrownewTypeError('Not an integer');There was a problem hiding this comment.
or are you just short-circuiting for the fast path?
There was a problem hiding this comment.
This is a legacy functionality it seems. If we pass an fd to truncate it internally delegates it to ftruncate. So we cannot throw error here. We are just checking if it is a positive integer and move on to the next check if is not.
Are you suggesting to not to call ftruncate at all?
There was a problem hiding this comment.
I just followed the logic paths for current and this patch, and there seemed to be a discrepancy.
There was a problem hiding this comment.
@trevnorris Agree, but wouldn't this check be better?
There was a problem hiding this comment.
My assumption was to land most these changes on a minor, then making any breaking changes, that push this to semver-major, to another PR. If you're cool with this staying on major then I'll have another look from that perspective.
There was a problem hiding this comment.
@trevnorris I am okay with this being in major :-) Let's get this done right. Please suggest improvements as well :-)
thefourtheye
commented
Sep 21, 2015
Bump! |
There was a problem hiding this comment.
Change this and the below line to:
CHECK(args[1]->IsNumber());
constint64_t = args[1]->IntegerValue();Reason for the CHECK() is because we're now making an assumption about the incoming value. Always want to catch that if incorrect, because at this point if the value is incorrect then we've screwed up.
There was a problem hiding this comment.
wait. nm. read this as the fd value, not the len value.
EDIT: meaning, no need for the CHECK(). can still collapse the other.
trevnorris
commented
Sep 21, 2015
to recap
|
Fishrock123
commented
Oct 19, 2015
ping @thefourtheye |
targos
commented
Jan 31, 2016
ping @thefourtheye ;) |
thefourtheye
commented
Jan 31, 2016
@targos Ah, I have this open for a loooong time. I'll get to it this week. Thanks for reminding :-) Last week @benjamingr also reminded me of this. |
000eee8 to
8233f9aComparethefourtheye
commented
Feb 12, 2016
@trevnorris Sorry for the delay in getting your review comments addressed. PTAL. |
jasnell
commented
Feb 13, 2016
Added semver-major tag based on the discussion thread. Feel free to change that if it turns out not to be major after all. |
There was a problem hiding this comment.
Change this to a TypeError. Also I'd replace "positive" with "unsigned".
6036668 to
3aab026Comparethefourtheye
commented
Mar 14, 2016
@trevnorris Changed positive to unsigned now. |
3aab026 to
f0b3208Comparetrevnorris
commented
Jul 20, 2016
Thanks for the change, and test. LGTM. |
7a953f9 to
f19c403Comparethefourtheye
commented
Jul 21, 2016
Rebased and improved the |
This patch moves the basic validation of arguments to `truncate` family of functions to the JavaScript from the C++ layer.
f19c403 to
693f14eComparethefourtheye
commented
Jul 21, 2016
Rebased, after landing #7168. CI Run: https://ci.nodejs.org/job/node-test-pull-request/3378/ |
thefourtheye
commented
Jul 21, 2016
Landed in c86c1ee. |
This patch 1. moves the basic validation of arguments to `truncate` family of functions to the JavaScript layer from the C++ layer. 2. makes sure that the File Descriptors are validated strictly. PR-URL: #2498 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This reverts commit c86c1ee. original commit message: This patch 1. moves the basic validation of arguments to `truncate` family of functions to the JavaScript layer from the C++ layer. 2. makes sure that the File Descriptors are validated strictly. PR-URL: nodejs#2498 Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This reverts commit c86c1ee. original commit message: This patch 1. moves the basic validation of arguments to `truncate` family of functions to the JavaScript layer from the C++ layer. 2. makes sure that the File Descriptors are validated strictly. PR-URL: nodejs#2498 Reviewed-By: Trevor Norris <trev.norris@gmail.com> PR-URL: nodejs#7950 Reviewed-By: Julien Gilli <jgilli@nodejs.org> Reviewed-By: Rod Vagg <rod@vagg.org> Reviewed-By: Minwoo Jung <jmwsoft@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This patch moves the basic validation of arguments to
truncatefamilyof functions to the JavaScript from the C++ layer.
cc @bnoordhuis
CI Run: https://jenkins-iojs.nodesource.com/job/node-test-pull-request/131/