xpcshell's readline function truncates its result after 255 characters

NEW
Unassigned

Status

()

Core
XPConnect
4 years ago
a year ago

People

(Reporter: florian, Unassigned)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
Created attachment 8363147 [details] [diff] [review]
fix-xpcshell-readline.patch

The ReadLine function uses a 4k buffer at:
http://hg.mozilla.org/mozilla-central/annotate/1b52aa569ced/js/xpconnect/src/XPCShellImpl.cpp#l210
211 ReadLine(JSContext *cx, unsigned argc, jsval *vp)
212 {
213     CallArgs args = CallArgsFromVp(argc, vp);
214 
215     // While 4096 might be quite arbitrary, this is something to be fixed in
216     // bug 105707. It is also the same limit as in ProcessFile.
217     char buf[4096];

But calls GetLine which has a buffer of size 256 at:
http://hg.mozilla.org/mozilla-central/annotate/1b52aa569ced/js/xpconnect/src/XPCShellImpl.cpp#l200
197 static bool
198 GetLine(JSContext *cx, char *bufp, FILE *file, const char *prompt) {
199     {
200         char line[256] = { '\0' };


Truncating after 255 characters makes the readline function quite disappointing (if not fully unusable for scripts passing JSON around).

The attached patch copies the implementation from the js shell which doesn't have this limitation. The patch is imperfect and already bitrotted, but I thought I would share, just in case someone runs into the same issue. I'm not going to work more on this in the near future, anybody interested should feel free to update the patch/write another better patch.
I just verified that as of Firefox 48 the limit is 1024 when input comes from a TTY. Same for current Nightly.
You need to log in before you can comment on or make changes to this bug.