Граф коммитов

70 Коммитов

Автор SHA1 Сообщение Дата
Emilio Cobos Álvarez 00f5ea846d Bug 1755896 - Add support from AString to ACString Base64 decoding. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D139029
2022-02-18 10:42:10 +00:00
Simon Giesecke 1c53236b70 Bug 1679272 - Include ScopeExit.h exactly where used. r=andi
Differential Revision: https://phabricator.services.mozilla.com/D98888
2020-12-07 14:25:59 +00:00
Simon Giesecke f77f8fd84c Bug 1659674 - Change BulkWrite to return mozilla::Result. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D87419
2020-08-21 09:54:48 +00:00
Bogdan Tara a904137456 Backed out changeset 0327b662a05f (bug 1659674) for nsStorageStream related central bustage CLOSED TREE 2020-08-20 02:58:41 +03:00
Simon Giesecke cfd7d0ea9c Bug 1659923 - Avoid unnecessary copies around Base64Encode. r=xpcom-reviewers,necko-reviewers,froydnj,valentin
This also adds some more variants of Base64Encode and Base64EncodeAppend.

Differential Revision: https://phabricator.services.mozilla.com/D87559
2020-08-19 17:45:16 +00:00
Simon Giesecke 0541f523d9 Bug 1659679 - Unify overflow handling in Base64.cpp encoding functions. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D87461
2020-08-19 10:52:25 +00:00
Simon Giesecke 9352526320 Bug 1659674 - Change BulkWrite to return mozilla::Result. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D87419
2020-08-19 14:39:03 +00:00
Simon Giesecke 55a58f0a61 Bug 847347 - Ensure that FileReader::GetAsDataURL does not trigger a release-mode assertion failure on large files. r=jstutte,froydnj
We avoid going through Substring which imposes a limit on the string length of
INT32_MAX and failing a MOZ_RELEASE_ASSERT otherwise.

This adds a new `Base64EncodeAppend` function that takes 8-bit char input and
produces 16-bit char output, and appends to an existing string, which is what
we need here to avoid doing a large copy. Base64EncodeHelper is generalized
to accomodate for that.

So in addition to fixing the defect, this also optimizes performance and
memory usage.

Differential Revision: https://phabricator.services.mozilla.com/D87413
2020-08-19 08:11:42 +00:00
Andrea Marchesini 45f7415671 Bug 1650811 - Make Base64 compatible with ReadSegments() with small buffers, r=asuth,necko-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D82522
2020-07-13 08:34:07 +00:00
Konstantin Morozov ea1011eb87 Bug 1629432 - converting integer literal to bool. r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D71181
2020-04-16 14:14:08 +00:00
Chris Peterson b1f54173e8 Bug 1624776 - Replace MOZ_MUST_USE with [[nodiscard]] in xpcom. r=xpcom-reviewers,KrisWright
Also move MOZ_MUST_USE before function declarations' specifiers and return type. While clang and gcc's __attribute__((warn_unused_result)) can appear before, between, or after function specifiers and return types, the [[nodiscard]] attribute must precede the function specifiers.

Also remove MOZ_MUST_USE from nsIMemoryReporter's function pointer typedefs. [[nodiscard]] is an attribute of a function's declaration, not the function's type, and thus can't be applied to function pointers or lambdas.

Differential Revision: https://phabricator.services.mozilla.com/D68138

--HG--
extra : moz-landing-system : lando
2020-03-27 17:21:48 +00:00
Sylvestre Ledru 265e672179 Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset

--HG--
extra : amend_source : 4d301d3b0b8711c4692392aa76088ba7fd7d1022
2018-11-30 11:46:48 +01:00
Henri Sivonen 34a614ae14 Bug 1488186 - Avoid writing past the logical length of a string in Base64URLEncode. r=froydnj
MozReview-Commit-ID: 4Sv7fHYIT9n

Differential Revision: https://phabricator.services.mozilla.com/D4912

--HG--
extra : moz-landing-system : lando
2018-09-04 18:24:52 +00:00
Henri Sivonen d733f8a4f2 Bug 1484987 - Avoid writing past the logical length of a string in XPCOM. r=froydnj
MozReview-Commit-ID: 3qkhOiQduLQ

Differential Revision: https://phabricator.services.mozilla.com/D3883

--HG--
extra : moz-landing-system : lando
2018-08-30 11:09:27 +00:00
Andreea Pavel eb68a1e6db Backed out changeset 097c92352197 (bug 1484987) for failing gtests at Base64.TruncateOnInvalidDecodeCString on a CLOSED TREE 2018-08-29 10:15:50 +03:00
Henri Sivonen a459f8cbf4 Bug 1484987 - Avoid writing past the logical length of a string in XPCOM. r=froydnj
MozReview-Commit-ID: 3qkhOiQduLQ

Differential Revision: https://phabricator.services.mozilla.com/D3883

--HG--
extra : moz-landing-system : lando
2018-08-29 06:04:57 +00:00
Andreea Pavel a7c7a16e37 Backed out changeset 9216e8942ed6 (bug 1484987) for build bustages at builds/worker/workspace/build/src/xpcom/io/nsStorageStream.cpp on a CLOSED TREE 2018-08-29 08:36:19 +03:00
Henri Sivonen 5969209bdc Bug 1484987 - Avoid writing past the logical length of a string in XPCOM. r=froydnj
MozReview-Commit-ID: 3qkhOiQduLQ

Differential Revision: https://phabricator.services.mozilla.com/D3883

--HG--
extra : moz-landing-system : lando
2018-08-28 14:29:40 +00:00
Chris Peterson 2afd829d0f Bug 1469769 - Part 6: Replace non-failing NS_NOTREACHED with MOZ_ASSERT_UNREACHABLE. r=froydnj
This patch is an automatic replacement of s/NS_NOTREACHED/MOZ_ASSERT_UNREACHABLE/. Reindenting long lines and whitespace fixups follow in patch 6b.

MozReview-Commit-ID: 5UQVHElSpCr

--HG--
extra : rebase_source : 4c1b2fc32b269342f07639266b64941e2270e9c4
extra : source : 907543f6eae716f23a6de52b1ffb1c82908d158a
2018-06-17 22:43:11 -07:00
Sylvestre Ledru 916f2bbd02 Bug 1413490 - Base64.cpp: disable the formatting of kBase64DecodeTable & kBase64URLDecodeTable r=erahm
MozReview-Commit-ID: GvvwGp8vlxC

--HG--
extra : rebase_source : 1d20be5438feb345265be5398bd30aca1e932b70
2017-11-01 11:24:37 +01:00
Nathan Froyd 3ac61243c3 Bug 1362449 - part 12 - avoid conversions in nsString Base64 decoding; r=erahm
After all the previous work, we can now base64 decode nsString types
without intermediate conversion steps to nsCString, which is faster and
more memory-efficient.
2017-09-06 16:58:36 -04:00
Nathan Froyd 1506c036e9 Bug 1362449 - part 11 - fix decoding subroutines to cope with wide output types; r=erahm
The result of decoding needs to be an explicit 8-bit type before being
widened to the output type to avoid undesirable effects like sign
extension.
2017-09-06 16:58:36 -04:00
Nathan Froyd bd7f988c20 Bug 1362449 - part 10 - templatify CString base64 decode routine; r=erahm
The current nsString decoding routine indirectly relies on the various
checks this routine performs; making it generic over string types
ensures that we can eventually call it directly from the nsString
decoding routine.
2017-09-06 16:58:36 -04:00
Nathan Froyd d44ccf35ff Bug 1362449 - part 9 - templatify core base64 decode routine; r=erahm
Similar to the work we did for encoding, we're going to want this to be
type-generic.
2017-09-06 16:58:36 -04:00
Nathan Froyd 9cab40ef08 Bug 1362449 - part 8 - use our base64 decoding routines instead of NSPR's; r=erahm
Our base64 decoding routines are a little nicer, and using them is a
necessary step to templating all the necessary routines.
2017-09-06 16:58:36 -04:00
Nathan Froyd 602ae06673 Bug 1362449 - part 7 - make decode routines type-generic; r=erahm
The existing Base64URL code converts from `const char` to `uint8_t`.
We're going to want versions that convert from character types to
character types, so make the decode routines accept generic input and
output types.
2017-09-06 16:58:36 -04:00
Nathan Froyd 84d527a6e0 Bug 1362449 - part 6 - factor out base64url decoding routines; r=erahm
The decoding logic is the same for Base64 and Base64URL; we might as
well reuse the routines that we already have for Base64URL decoding so
we don't make mistakes in the logic.
2017-09-06 16:58:37 -04:00
Nathan Froyd 844466bd3f Bug 1362449 - part 5 - add tables for normal base64 decoding; r=erahm
These tables are nearly identical to the ones for base64url decoding,
but ideally will be slightly more readable, since things are broken up
into sets of eight entries at a time.
2017-09-06 16:58:37 -04:00
Nathan Froyd 7e9f8459e0 Bug 1362449 - part 4 - avoid conversions in nsString Base64 encoding; r=erahm
After all the previous work, we can base64 encoding nsString values
directly into nsString values, without having to go through intermediate
nsCString values.  Since this routine backs base64 routines exposed to
the web, this change should help with OOMs that we see associated with
base64 encoding.
2017-09-06 16:58:37 -04:00
Nathan Froyd d68341d832 Bug 1362449 - part 3 - templatify core nsCString base64 encode routine; r=erahm
The nsACString -> nsACString encode routine has several checks in it for
correct operation, and the nsAString -> nsAString encode routine relies
on those checks happening via the nsACString -> nsACString routine.
Once we start encoding nsAStrings directly, we'll still need those
checks, and the easiest way to ensure they happen is to move the core
base64 encode logic for strings into a templated helper.
2017-09-06 16:58:37 -04:00
Nathan Froyd fe35e37738 Bug 1362449 - part 2 - use our Base64 encode implementation rather than NSPR's; r=erahm
One less use of NSPR is a good thing.  The failure cases that
PL_Base64Encode would have caught for us are:

1. "Truncation".
2. Integer overflow when computing destination string length.
3. Malloc failures.

The first one only gets checked if we pass in zero for the source
length, which we never do.  The latter two only get checked if we pass
in a null pointer for the destination, which we never do.  So removing
the error handling PL_Base64Encode implies here is a good thing.
2017-09-06 16:58:37 -04:00
Nathan Froyd 329a43dc67 Bug 1362449 - part 1a - fix Encode*to* for non-8-bit character types; r=erahm
We need to explicitly reduce the incoming character to 8 bits, rather
than assuming that a conversion to uint32_t will do the right thing.
2017-09-06 16:58:37 -04:00
Nathan Froyd 261bd97797 Bug 1362449 - part 1 - make Base64 encode generic over source character types; r=erahm
We'll need this to implement direct encoding from nsString, and the
changes are trivial.
2017-09-06 16:58:37 -04:00
Nathan Froyd 844bb853dd Bug 1362390 - make Base64Encode tolerant of allocation failures; r=mccr8 2017-05-05 11:33:36 -04:00
Nathan Froyd 880d162a51 Bug 1362194 - part 3 - make Base64Decode even more tolerant of allocation failures; r=mccr8
The lossy conversion to ASCII here can also fail; we should handle that
as well.  Rewriting the code to use MakeScopeExit also avoids tangled
logic and/or duplicating calls to ensure the destination string is
truncated on failure.
2017-05-05 11:33:36 -04:00
Nathan Froyd 8b000da91e Bug 1362194 - part 2 - make Base64Decode tolerant of allocation failures; r=mccr8
We need to use a fallible CopyASCIItoUTF16 function, since we might not
have enough memory to perform the copy.
2017-05-05 11:33:36 -04:00
Tomislav Jurin 348bfffc19 Bug 1296189 - Replace NS_RUNTIMEABORT("some string literal message") with MOZ_CRASH(). r=froydnj 2016-12-02 13:46:53 -08:00
Andi-Bogdan Postelnicu f2739cfe8d Bug 1296286 - preventfalse positive resource leak trigger in Base64DecodeHelper. r=froydnj
MozReview-Commit-ID: 6E8ftV093ep

--HG--
extra : rebase_source : 10e39c2be69471c2e4c9df14cfc067c8e78c227f
2016-08-18 16:40:04 +03:00
Nicholas Nethercote 3b0485fcdb Bug 1294645 - Don't use NS_CALLBACK for callbacks in nsI{Input,Output,UnicharInput},Stream.idl. r=froydnj.
Slightly less than half (93 / 210) of the NS_METHOD instances in the codebase
are because of the use of NS_CALLBACK in
nsI{Input,Output,UnicharInput},Stream.idl. The use of __stdcall on Win32 isn't
important for these callbacks because they are only used as arguments to
[noscript] methods.

This patch converts them to vanilla |nsresult| functions. It increases the size
of xul.dll by about ~600 bytes, which is about 0.001%.

--HG--
extra : rebase_source : c15d85298e0975fd030cd8f8f8e54501f453959b
2016-08-12 17:36:22 +10:00
Nicholas Nethercote c10a40d45c Bug 1275309 (part 1) - Add a variant of Base64Decode(). r=erahm.
This mirrors the changes made to encoding in bug 1273712.

--HG--
extra : rebase_source : 9902fa6aa7460ad04969b69f679e438e4850944d
2016-08-04 11:49:46 +10:00
Nicholas Nethercote ebf2837e7e Bug 1273712 (part 2) - Add a new overloading of Base64Encode(). r=erahm.
This will be used in bug 1273711 to avoid an OOM.

This also tweaks one of the existing overloadings of Base64Encode to return
NS_ERROR_OUT_OF_MEMORY on OOM instead of NS_ERROR_INVALID_ARG.

--HG--
extra : rebase_source : a2ad472b11ac2c858487bf5fdae84d183084773b
2016-05-19 08:55:46 +10:00
Nicholas Nethercote 47eac9822f Bug 1273712 (part 1) - Rename arguments and variables in Base64.{h,cpp}. r=erahm.
The argument naming in Base64.{h,cpp} is horribly confused, with a lot of them
gotten backwards. This patch fixes that, and also introduces a more consistent
naming scheme for arguments and local variables: "binary" is used for binary
data, and "base64" is used for base64-encoded data.

This patch doesn't change any functionality.

--HG--
extra : rebase_source : 7d8a08762e291851bd117a0409fc8715b830fdbe
2016-05-19 08:53:50 +10:00
Kit Cambridge b3e4980239 Bug 1266569 - Avoid including the `ChromeUtils` binding in `Base64.h`. r=froydnj
MozReview-Commit-ID: 8ZLdMhJMaUe

--HG--
extra : rebase_source : d5cb2b5bcc587bad95e6223d18ef38c6937f9270
extra : histedit_source : 208b28d87e223333c2995fd615e0602b11d5bb68
2016-04-22 07:41:58 -07:00
Kit Cambridge d21d6da5e8 Bug 1256488 - Add a Base64 URL-decoder for C++ and chrome JS callers. r=mt,baku
MozReview-Commit-ID: IrDwImYfHRu

--HG--
extra : rebase_source : ed7da7447e5d70c596234961625fcd4b8139814f
2016-03-22 12:09:04 -07:00
Kit Cambridge 1c0dc1a969 Bug 1205137 - Add a `PushSubscription` serializer. r=mt,smaug
--HG--
extra : commitid : F5xjqIFcach
extra : rebase_source : 61b0a0cbae318f7afc51752fc31a7133b8abd15c
2015-12-14 16:28:19 -08:00
Birunthan Mohanathas a8939590de Bug 1182996 - Fix and add missing namespace comments. rs=ehsan
The bulk of this commit was generated by running:

  run-clang-tidy.py \
    -checks='-*,llvm-namespace-comment' \
    -header-filter=^/.../mozilla-central/.* \
    -fix
2015-07-13 08:25:42 -07:00
Titi_Alone cc4df63d2e Bug 1133063 - Move SetLength into the if's condition. r=froydnj 2015-02-26 19:13:59 +01:00
Nicholas Nethercote 242708cf72 Bug 1127201 (attempt 2, part 1) - Replace most NS_ABORT_IF_FALSE calls with MOZ_ASSERT. r=Waldo.
--HG--
extra : rebase_source : 488e401ff87e31a2074c4108c4df0572d9536667
2015-02-09 14:34:50 -08:00
Andrew McCreight d3826daa16 Back out Bug 1127201 (part 2) for various problems. 2015-02-06 15:04:32 -08:00
Nicholas Nethercote d34f0301b8 Bug 1127201 (part 2) - Convert all NS_ABORT_IF_FALSE calls to MOZ_ASSERT. r=Waldo.
--HG--
extra : rebase_source : 99182e70335d2b5ff95f8c528ae992d37294be3a
2015-02-04 20:05:36 -08:00