diff options
author | Tomasz Iwanek <t.iwanek@samsung.com> | 2015-01-08 12:38:09 +0100 |
---|---|---|
committer | Tomasz Iwanek <t.iwanek@samsung.com> | 2015-01-23 15:41:36 +0100 |
commit | ba88187b2c0c50d5f4280e6b3770b17673611faa (patch) | |
tree | 086e4c9f26fbcb82d542bb400455c2019e4d1b69 | |
parent | e36cdeba173a93b72110b536094220e1a00c566c (diff) | |
download | bundle-ba88187b2c0c50d5f4280e6b3770b17673611faa.tar.gz bundle-ba88187b2c0c50d5f4280e6b3770b17673611faa.tar.bz2 bundle-ba88187b2c0c50d5f4280e6b3770b17673611faa.zip |
Fix crash if argument number is wrong in bundle_import_from_argv
By introducing this, if argument number will be wrong, the not matching
argument will be skipped.
I would prefer not to return error as I'm not sure
if platform will use it correctly.
Change-Id: I71544a50e7959e7a77718e221382ac400437eb95
-rwxr-xr-x | src/bundle.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/bundle.c b/src/bundle.c index 2d9902c..69b37dd 100755 --- a/src/bundle.c +++ b/src/bundle.c @@ -757,7 +757,7 @@ bundle_import_from_argv(int argc, char **argv) { /*BUNDLE_LOG_PRINT("\nit is not encoded");*/ int idx; - for (idx = 1; idx < argc; idx = idx + 2) { /*start idx from one as argv[1] is user given argument*/ + for (idx = 1; idx + 1 < argc; idx = idx + 2) { /*start idx from one as argv[1] is user given argument*/ bundle_add(b, argv[idx], argv[idx + 1]); } return b; @@ -769,7 +769,7 @@ bundle_import_from_argv(int argc, char **argv) unsigned char *byte = NULL; char *encoded_byte; unsigned int byte_size; - for(idx = 2; idx < argc; idx = idx+2) { // start idx from 2 as argv[1] is encoded + for(idx = 2; idx + 1 < argc; idx = idx+2) { // start idx from 2 as argv[1] is encoded kv = NULL; kva = NULL; |