Commit Graph

29 Commits

Author SHA1 Message Date
Peter Marschall 5abe99d228 fix typos
Mass-typo fixing, almost exclusively in comments and text strings.

While at it also fixed a few (very few) grammar errors.
2018-04-15 09:34:45 +02:00
Frank Morgner 6bfb39454b Fix missing error handling of memory allocation (#1020)
* libopensc: handle allocation errors
* handle more faults during memory allocation

fixes several situations that cause segmentation fault
2017-04-20 21:08:49 +02:00
Frank Morgner c5e40127d0 Coverity fixes (#1012)
card-cac.c
 * CLANG_WARNING: The left operand of '<' is a garbage value
card-coolkey.c
 * CLANG_WARNING: overwriting variable
 * CPPCHECK_WARNING: memory leak / overwrite variable
 * CLANG_WARNING: null pointer dereference
 * UNUSED_VALUE: unused return value
card-gids.c
 * CLANG_WARNING: Branch condition evaluates to a garbage value
 * SIZEOF_MISMATCH: suspicious_sizeof
card-myeid.c
 * RESOURCE_LEAK: Variable "buf" going out of scope leaks the storage it points to.
 * CLANG_WARNING: overwriting variable
 * (rewrite not to confuse coverity)
pkcs15-cac.c
 * RESOURCE_LEAK: Variable "cert_out" going out of scope leaks the storage it points to.
pkcs15-coolkey.c
 * UNUSED_VALUE: unused return value
pkcs15-piv.c
 * RESOURCE_LEAK: Variable "cert_out" going out of scope leaks the storage it points to.
pkcs15-sc-hsm.c
 * DEADCODE
pkcs11/framework-pkcs15.c
 * RESOURCE_LEAK: Variable "p15_cert" going out of scope leaks the storage it points to.
pkcs15init/pkcs15-lib.c
 * CLANG_WARNING: Assigned value is garbage or undefined
pkcs15init/pkcs15-myeid.c
 * UNREACHABLE: Probably wrong placement of code block
tests/p15dump.c
 * IDENTICAL_BRANCHES
pkcs15-init.c
 * CLANG_WARNING: Potential leak of memory pointed to by 'args.der_encoded.value'
pkcs15-tool.c
 * RESOURCE_LEAK: Variable "cert" going out of scope leaks the storage it points to.
 * MISSING_BREAK: The above case falls through to this one.
sc-hsm-tool.c
 * CLANG_WARNING: Potential leak of memory pointed to by 'sp'
westcos-tool.c
 * FORWARD_NULL: Passing null pointer "pin" to "unlock_pin", which dereferences it.
 * (rewrite not to confuse coverity)
card-cac.c
* Avoid malloc with 0 argument
gids-tool.c
* FORWARD_NULL -- copy&paste error
scconf.c
* CLANG_WARNING: Call to 'malloc' has an allocation size of 0 bytes

closes #982
2017-04-03 13:43:30 +02:00
Frank Morgner 836842a6bb remove unused `scconf_entry` 2016-06-14 14:57:58 +02:00
Viktor Tarasov f641ebd248 fixed errors reported by cppcheck: part 1
partially applied the pull request #182 from Frank Morgner -- updated the common frameworks source files
2013-09-29 20:28:45 +02:00
Viktor Tarasov 73f324010e config: ignore non 'auto-configurated' values
When getting string configuration parameter,
ignore non 'auto-configurated' in configuration file value
(ex. @SOME_VALUE_IN_OPENSC_CONF@) and return it's default value.
2012-06-08 20:17:36 +02:00
ludovic.rousseau 19343c77e2 Remove dead code
scconf.c:195:2: warning: Value stored to 'ret' is never read
        ret = scconf_put_str(block, option, !value ? "false" : "true");
        ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scconf.c:585:3: warning: Value stored to 'r' is never read
                r = 0;
                ^   ~
scconf.c:711:3: warning: Value stored to 'r' is never read
                r = 0;
                ^   ~


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@5139 c6295689-39f2-0310-b995-f0e70906c6a9
2011-02-05 20:25:08 +00:00
ludovic.rousseau f47416d60e Do not cast the return value of malloc(3) and calloc(3)
From http://en.wikipedia.org/wiki/Malloc#Casting_and_type_safety
" Casting and type safety

malloc returns a void pointer (void *), which indicates that it is a
pointer to a region of unknown data type. One may "cast" (see type
conversion) this pointer to a specific type, as in

int *ptr = (int*)malloc(10 * sizeof (int));

When using C, this is considered bad practice; it is redundant under the
C standard. Moreover, putting in a cast may mask failure to include the
header stdlib.h, in which the prototype for malloc is found. In the
absence of a prototype for malloc, the C compiler will assume that
malloc returns an int, and will issue a warning in a context such as the
above, provided the error is not masked by a cast. On certain
architectures and data models (such as LP64 on 64 bit systems, where
long and pointers are 64 bit and int is 32 bit), this error can actually
result in undefined behavior, as the implicitly declared malloc returns
a 32 bit value whereas the actually defined function returns a 64 bit
value. Depending on calling conventions and memory layout, this may
result in stack smashing.

The returned pointer need not be explicitly cast to a more specific
pointer type, since ANSI C defines an implicit conversion between the
void pointer type and other pointers to objects. An explicit cast of
malloc's return value is sometimes performed because malloc originally
returned a char *, but this cast is unnecessary in standard C
code.[4][5] Omitting the cast, however, creates an incompatibility with
C++, which does require it.

The lack of a specific pointer type returned from malloc is type-unsafe
behaviour: malloc allocates based on byte count but not on type. This
distinguishes it from the C++ new operator that returns a pointer whose
type relies on the operand. (see C Type Safety). "

See also
http://www.opensc-project.org/pipermail/opensc-devel/2010-August/014586.html


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4636 c6295689-39f2-0310-b995-f0e70906c6a9
2010-08-18 15:08:51 +00:00
aj d22a2483c0 Header file cleanup.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@4081 c6295689-39f2-0310-b995-f0e70906c6a9
2010-03-04 08:14:36 +00:00
aj dce7d0024c oops, parm points to the first char, not to a pointer to the string.
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2730 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-05 22:09:28 +00:00
aj 1475978af5 remove unused variable item in scconf_put_str.
remove unused variable ret in scconf_put_int.
from the readme: "if parm not NULL, then ... parm points to ..."
so we need to get the value of the location where it points to.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2729 c6295689-39f2-0310-b995-f0e70906c6a9
2005-12-05 22:07:54 +00:00
nils f044157553 fix incorrect use of realloc (x = realloc(x, y) doesn't free
the x in case of a failure)


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1775 c6295689-39f2-0310-b995-f0e70906c6a9
2004-04-21 18:10:58 +00:00
aet c13a417d8b - Add scconf_list_toarray() by Jamie Honan
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1617 c6295689-39f2-0310-b995-f0e70906c6a9
2003-11-20 14:13:08 +00:00
aet 0ca5922274 Merge with dvbsak.sf.net
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@715 c6295689-39f2-0310-b995-f0e70906c6a9
2002-11-12 14:32:17 +00:00
aet 8a9bd1272e Added new functions:
scconf_put_{str,int,bool}
scconf_write_entries

TODO:
- Cleanups, add more sanity checks
- Rewrite parts of the API for LDAP support


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@711 c6295689-39f2-0310-b995-f0e70906c6a9
2002-11-11 22:26:06 +00:00
aet da615f3eea Oops
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@710 c6295689-39f2-0310-b995-f0e70906c6a9
2002-11-11 14:27:48 +00:00
aet d9cd213345 Checkpoint commit. Added new functions:
scconf_block_{add,copy}
scconf_item_{add,copy,destroy}
scconf_list_copy


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@709 c6295689-39f2-0310-b995-f0e70906c6a9
2002-11-11 14:08:45 +00:00
fabled 7635468ed9 - Initial support for win32
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@654 c6295689-39f2-0310-b995-f0e70906c6a9
2002-06-14 12:52:56 +00:00
aet 25cf9756ed Minor GCC warning fixes
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@606 c6295689-39f2-0310-b995-f0e70906c6a9
2002-05-20 09:19:41 +00:00
aet 3dccd63989 - C++ support. Compiles with gcc/g++ for Linux, otherwise
completely untested.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@574 c6295689-39f2-0310-b995-f0e70906c6a9
2002-04-19 14:23:31 +00:00
aet b2a10c12e7 Remove flag SCCONF_OPTIONAL, add SCCONF_MANDATORY
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@410 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-31 19:15:04 +00:00
aet 70306822d2 Include header stdio.h
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@408 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-31 16:00:29 +00:00
aet d9f44ecde3 Upgrade test-conf to use scconf_parse_entries();
NOTE: Handles ldap/card blocks for scldap.conf


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@406 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-31 13:00:41 +00:00
aet eb7b050a1d Add functions scconf_list_add and scconf_parse_entries,
getting the values in user code is now pretty much the
same as it is in ASN.1 decoder.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@405 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-31 11:30:54 +00:00
aet 19f7f1073a Rename scconf_init to scconf_new
Rename scconf_deinit to scconf_free
Add initial comments to scldap.h


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@398 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-26 20:56:13 +00:00
aet b2d2bc77ae Rename scconf_find_value to scconf_find_list
Rename scconf_find_value_first to scconf_get_str
Add functions scconf_get_int and scconf_get_bool


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@395 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-25 22:39:22 +00:00
aet c69d1b59df Always allocate scconf_list for block structure
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@394 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-25 21:23:32 +00:00
aet aa5ec6bae1 Add sanity checks and more comments
Add new parameter for scconf_find_blocks


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@393 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-25 20:10:44 +00:00
aet 0f95c1c6de Start merging various sources from project SCIDI - smart card
identification infrastructure by Helsinki University of Technology.

Breaks current PAM build, lot's of stuff from configure.ac
missing, some references to unknown sources and functions.

Time to get some sleep, i'll continue merging tomorrow.


git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@356 c6295689-39f2-0310-b995-f0e70906c6a9
2002-03-20 23:21:22 +00:00