You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 41 Next »

The following table lists the CERT C Coding Standard rules and recommendations, and states their applicability to the development of Android applications. Applicable means that the rule can be applied to general C platforms including Android. Applicable? means that one reviewer found the rule to be applicable to the Android platform, but we are waiting for that to be verified. Applicable in principle means that the rule can be applied to Android but the examples currently shown in the rule are not yet relevant to Android. Not applicable means that the rule cannot be applied to Android platforms. A '?' indicates that applicability has not yet been determined.

 

Rule or Recommendation
Applicable to Android Application Development?
Comments
RecommendationsAndroid app development applicable?Comments
PRE00-C. Prefer inline or static functions to function-like macrosApplicable 
PRE01-C. Use parentheses within macros around parameter namesApplicable 
PRE02-C. Macro replacement lists should be parenthesizedApplicable 
PRE03-C. Prefer typedefs to defines for encoding typesApplicable 
PRE04-C. Do not reuse a standard header file nameApplicable 
PRE05-C. Understand macro replacement when concatenating tokens or performing stringificationApplicable 
PRE06-C. Enclose header files in an inclusion guardApplicable 
PRE07-C. Avoid using repeated question marksApplicable 
PRE08-C.   Guarantee that header file names are uniqueApplicable 
PRE09-C. Do not replace secure functions with deprecated or obsolescent functionsApplicable 
PRE10-C. Wrap multistatement macros in a do-while loopApplicable 
PRE11-C. Do not conclude macro definitions with a semicolonApplicable 
PRE12-C. Do not define unsafe macrosApplicable 
PRE13-C. Use the Standard predefined macros to test for versions and features.Applicable 
RulesAndroid app development applicable?Comments
PRE30-C. Do not create a universal character name through concatenationApplicable 
PRE31-C. Avoid side effects in arguments to unsafe macrosApplicable 
PRE32-C. Do not use preprocessor directives in invocations of function-like macrosApplicable 
RecommendationsAndroid app development applicable?Comments
DCL00-C. Const-qualify immutable objectsApplicable 
DCL01-C. Do not reuse variable names in subscopesApplicable 
DCL02-C. Use visually distinct identifiersApplicable 
DCL03-C. Use a static assertion to test the value of a constant expressionApplicable 
DCL04-C. Do not declare more than one variable per declarationApplicable 
DCL05-C. Use typedefs of non-pointer types onlyApplicable 
DCL06-C. Use meaningful symbolic constants to represent literal valuesApplicable 
DCL07-C. Include the appropriate type information in function declaratorsApplicable 
DCL08-C. Properly encode relationships in constant definitionsApplicable 
DCL09-C. Declare functions that return errno with a return type of errno_tApplicable 
DCL10-C.   Maintain the contract between the writer and caller of variadic functionsApplicable 
DCL11-C.   Understand the type issues associated with variadic functionsApplicable 
DCL12-C.   Implement abstract data types using opaque typesApplicable 
DCL13-C.   Declare function parameters that are pointers to values not changed by the   function as constApplicable 
DCL15-C.   Declare file-scope objects or functions that do not need external linkage as   staticApplicable 
DCL16-C.   Use "L," not "l," to indicate a long valueApplicable 
DCL17-C.   Beware of miscompiled volatile-qualified variablesApplicable 
DCL18-C.   Do not begin integer constants with 0 when specifying a decimal valueApplicable 
DCL19-C.   Minimize the scope of variables and functionsApplicable 
DCL20-C.   Explicitly specify void when a function accepts no argumentsApplicable 
DCL21-C.   Understand the storage of compound literalsApplicable 
DCL22-C.   Use volatile for data that cannot be cachedApplicable 
DCL23-C.   Guarantee that mutually visible identifiers are uniqueApplicable 
RulesAndroid app development applicable?Comments
DCL30-C.   Declare objects with appropriate storage durationsApplicable 
DCL31-C.   Declare identifiers before using themApplicable 
DCL36-C.   Do not declare an identifier with conflicting linkage classificationsApplicable 
DCL37-C.   Do not declare or define a reserved identifierApplicable 
DCL38-C.   Use the correct syntax when declaring a flexible array memberApplicable Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
DCL39-C.   Avoid information leakage in structure paddingApplicable 
DCL40-C.   Do not create incompatible declarations of the same function or objectApplicable 
DCL41-C.   Do not declare variables inside a switch statement before the first case   labelApplicable 
RecommendationsAndroid app development applicable?Comments
EXP00-C.   Use parentheses for precedence of operationApplicable 
EXP02-C.   Be aware of the short-circuit behavior of the logical AND and OR operatorsApplicable 
EXP03-C.   Do not assume the size of a structure is the sum of the sizes of its membersApplicable 
EXP05-C.   Do not cast away a const qualificationApplicable 
EXP07-C.   Do not diminish the benefits of constants by assuming their values in   expressionsApplicable 
EXP08-C.   Ensure pointer arithmetic is used correctlyApplicable 
EXP09-C.   Use sizeof to determine the size of a type or variableApplicable 
EXP10-C.   Do not depend on the order of evaluation of subexpressions or the order in   which side effects take placeApplicable 
EXP11-C.   Do not make assumptions regarding the layout of structures with bit-fieldsApplicable 
EXP12-C.   Do not ignore values returned by functionsApplicable 
EXP13-C.   Treat relational and equality operators as if they were nonassociativeApplicable 
EXP14-C.   Beware of integer promotion when performing bitwise operations on integer   types smaller than intApplicable 
EXP15-C.   Do not place a semicolon on the same line as an if, for, or while statementApplicable 
EXP16-C.   Do not compare function pointers to constant valuesApplicable 
EXP17-C.   Do not perform bitwise operations in conditional expressionsApplicable 
EXP19-C.   Use braces for the body of an if, for, or while statementApplicable 
EXP20-C.   Perform explicit tests to determine success, true and false, and equalityApplicable 
EXP21-C.   Place constants on the left of equality comparisonsApplicable 
RulesAndroid app development applicable?Comments
EXP30-C.   Do not depend on the order of evaluation for side effectsApplicable 
EXP32-C.   Do not access a volatile object through a nonvolatile referenceApplicable 
EXP33-C.   Do not read uninitialized memoryApplicable 
EXP34-C.   Do not dereference null pointersApplicable 
EXP35-C.   Do not modify objects with temporary lifetime?Possibly C11 relevant material, relevance must be considered on Android.
EXP36-C.   Do not cast pointers into more strictly aligned pointer typesApplicable36C ARM chips more strict, X86 not so strict (so, relevant). 
EXP37-C.   Call functions with the correct number and type of argumentsApplicable 
EXP39-C.   Do not access a variable through a pointer of an incompatible typeApplicable 
EXP40-C.   Do not modify constant objectsApplicable 
EXP42-C.   Do not compare padding dataApplicable 
EXP43-C.   Avoid undefined behavior when using restrict-qualified pointersApplicable 
EXP44-C.   Do not rely on side effects in operands to sizeof, _Alignof, or _GenericApplicable 
EXP45-C.   Do not perform assignments in selection statementsApplicable 
RecommendationsAndroid app development applicable?Comments
INT00-C.   Understand the data model used by your implementation(s)Applicable 
INT01-C.   Use rsize_t or size_t for all integer values representing the size of an   objectApplicable 
INT02-C.   Understand integer conversion rulesApplicable 
INT04-C.   Enforce limits on integer values originating from tainted sourcesApplicable 
INT05-C.   Do not use input functions to convert character data if they cannot handle   all possible inputsApplicable 
INT06-C.   Use strtol() or a related function to convert a string token to an integerApplicable 
INT07-C.   Use only explicitly signed or unsigned char type for numeric valuesApplicable 
INT08-C.   Verify that all integer values are in rangeApplicable 
INT09-C.   Ensure enumeration constants map to unique valuesApplicable 
INT10-C.   Do not assume a positive remainder when using the % operatorApplicable 
INT12-C.   Do not make assumptions about the type of a plain int bit-field when used in   an expressionApplicable 
INT13-C.   Use bitwise operators only on unsigned operandsApplicable 
INT14-C.   Avoid performing bitwise and arithmetic operations on the same dataApplicable 
INT15-C.   Use intmax_t or uintmax_t for formatted IO on programmer-defined integer   typesApplicable 
INT16-C.   Do not make assumptions about representation of signed integersApplicable 
INT17-C.   Define integer constants in an implementation-independent mannerApplicable 
INT18-C.   Evaluate integer expressions in a larger size before comparing or assigning   to that sizeApplicable 
RulesAndroid app development applicable?Comments
INT30-C.   Ensure that unsigned integer operations do not wrapApplicable 
INT31-C.   Ensure that integer conversions do not result in lost or misinterpreted dataApplicable 
INT32-C.   Ensure that operations on signed integers do not result in overflowApplicable 
INT33-C.   Ensure that division and remainder operations do not result in divide-by-zero   errorsApplicable 
INT34-C.   Do not shift an expression by a negative number of bits or by greater than or   equal to the number of bits that exist in the operandApplicable 
INT35-C.   Use correct integer precisionsApplicable soonCurrently may not apply; if no 64-bit Android phones (although current   news says on the way)
INT36-C.   Converting a pointer to integer or integer to pointer?Don't know if a hardware platform for Android that this applies to. (only   apply to certain arcane platform)
RecommendationsAndroid app development applicable?Comments
FLP00-C.   Understand the limitations of floating-point numbersApplicable 
FLP01-C.   Take care in rearranging floating-point expressionsApplicable 
FLP02-C.   Avoid using floating-point numbers when precise computation is neededApplicable 
FLP03-C.   Detect and handle floating-point errorsApplicable 
FLP04-C.   Check floating-point inputs for exceptional valuesApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
FLP05-C.   Don't use denormalized numbersApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
FLP06-C.   Convert integers to floating point for floating-point operationsApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
FLP07-C.   Cast the return value of a function that returns a floating-point typeApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
RulesAndroid app development applicable?Comments
FLP30-C.   Do not use floating-point variables as loop countersApplicable 
FLP32-C.   Prevent or detect domain and range errors in math functionsApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
FLP34-C.   Ensure that floating-point conversions are within range of the new typeApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
FLP36-C.   Preserve precision when converting integral values to floating-point typeApplicableMaybe currently, a restriction on size of ints/doubles, etc. (64 bit   chips)
RecommendationsAndroid app development applicable?Comments
ARR00-C. Understand how arrays work?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR01-C.   Do not apply the sizeof operator to a pointer when taking the size of an   array?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR02-C.   Explicitly specify array bounds, even if implicitly defined by an initializer?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
RulesAndroid app development applicable?Comments
ARR30-C.   Do not form or use out-of-bounds pointers or array subscripts?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR32-C.   Ensure size arguments for variable length arrays are in a valid range?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR36-C.   Do not subtract or compare two pointers that do not refer to the same array?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR37-C.   Do not add or subtract an integer to a pointer to a non-array object?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR38-C.   Guarantee that library functions do not form invalid pointers?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
ARR39-C.   Do not add or subtract a scaled integer to a pointer?Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
RecommendationsAndroid app development applicable?Comments
STR00-C.   Represent characters using an appropriate typeApplicable 
STR01-C.   Adopt and implement a consistent plan for managing stringsApplicable 
STR02-C.   Sanitize data passed to complex subsystemsApplicable 
STR03-C.   Do not inadvertently truncate a stringApplicable 
STR04-C.   Use plain char for characters in the basic character setApplicable 
STR05-C.   Use pointers to const when referring to string literalsApplicable 
STR06-C.   Do not assume that strtok() leaves the parse string unchangedApplicable 
STR07-C.   Use the bounds-checking interfaces for remediation of existing string   manipulation codeApplicable 
STR08-C.   Use managed strings for development of new string manipulation codeApplicable 
STR09-C.   Don't assume numeric values for expressions with type plain characterApplicable 
STR10-C.   Do not concatenate different type of string literalsApplicable 
STR11-C.   Do not specify the bound of a character array initialized with a string   literalApplicable Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
RulesAndroid app development applicable?Comments
STR30-C.   Do not attempt to modify string literalsApplicableSTR: rest, yes
STR31-C.   Guarantee that storage for strings has sufficient space for character data   and the null terminatorApplicableSTR: rest, yes
STR32-C.   Do not pass a non-null-terminated character sequence to a library function   that expects a stringApplicable 
STR34-C.   Cast characters to unsigned char before converting to larger integer sizes?Can chars be unsigned on Android? Might be a compiler option, so yes. Not   needed for new code, but might have previous code affected by it.
STR37-C.   Arguments to character-handling functions must be representable as an   unsigned charApplicable 
STR38-C.   Do not confuse narrow and wide character strings and functions?Not sure, needs more investigation.
RecommendationsAndroid app development applicable?Comments
MEM00-C.   Allocate and free memory in the same module, at the same level of abstractionApplicable 
MEM01-C.   Store a new value in pointers immediately after free()Applicable 
MEM02-C.   Immediately cast the result of a memory allocation function call into a   pointer to the allocated typeApplicable 
MEM03-C.   Clear sensitive information stored in reusable resourcesApplicable 
MEM04-C.   Beware of zero-length allocationsApplicable 
MEM05-C.   Avoid large stack allocationsApplicable 
MEM06-C.   Ensure that sensitive data is not written out to diskApplicable 
MEM07-C.   Ensure that the arguments to calloc(), when multiplied, do not wrapApplicable 
MEM10-C.   Define and use a pointer validation functionApplicable 
MEM11-C.   Do not assume infinite heap spaceApplicable 
MEM12-C.   Consider using a goto chain when leaving a function on error when using and   releasing resourcesApplicable 
RulesAndroid app development applicable?Comments
MEM30-C.   Do not access freed memoryApplicable 
MEM31-C.   Free dynamically allocated memory when no longer neededApplicable 
MEM33-C.   Allocate and copy structures containing a flexible array member dynamicallyApplicable Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
MEM34-C.   Only free memory allocated dynamicallyApplicable 
MEM35-C.   Allocate sufficient memory for an objectApplicable 
MEM36-C.   Do not modify the alignment of objects by calling realloc()Applicable 
RecommendationsAndroid app development applicable?Comments
FIO01-C.   Be careful using functions that use file names for identification? 
FIO02-C.   Canonicalize path names originating from tainted sources? 
FIO03-C.   Do not make assumptions about fopen() and file creation? 
FIO05-C.   Identify files using multiple file attributes? 
FIO06-C.   Create files with appropriate access permissions? 
FIO08-C.   Take care when calling remove() on an open file? 
FIO09-C.   Be careful with binary data when transferring data across systems? 
FIO10-C.   Take care when using the rename() function? 
FIO11-C.   Take care when specifying the mode parameter of fopen()? 
FIO13-C.   Never push back anything other than one read character? 
FIO14-C.   Understand the difference between text mode and binary mode with file streams? 
FIO15-C.   Ensure that file operations are performed in a secure directory?FIO15-C: Look at Android/C interactions more closely to see if   applicable.
FIO17-C.   Do not rely on an ending null character when using fread()? 
FIO18-C.   Never expect fwrite() to terminate the writing process at a null character? 
FIO19-C.   Do not use fseek() and ftell() to compute the size of a regular file? 
FIO20-C.   Avoid unintentional truncation when using fgets() or fgetws()? 
FIO21-C.   Do not create temporary files in shared directories? 
FIO22-C.   Close files before spawning processes? 
FIO23-C.   Do not exit with unflushed data in stdout or stderr? 
RulesAndroid app development applicable?Comments
FIO30-C.   Exclude user input from format stringsApplicableUniversal
FIO31-C.   Do not open a file that is already open? 
FIO32-C.   Do not perform operations on devices that are only appropriate for files? 
FIO34-C.   Distinguish between characters read from a file and EOF or WEOF?EOF/WEOF: Only apply to app's public files? Others protected by VM?
FIO37-C.   Do not assume that fgets() or fgetws() returns a nonempty string when   successful? 
FIO38-C.   Do not copy a FILE object?FIO reference. What is Android   filesystem?     http://stackoverflow.com/questions/2421826/what-is-androids-file-system       It depends on what filesystem, for example /system and /data are yaffs2   while /sdcard is vfat     By default, it uses YAFFS - Yet Another Flash File System.     Depends on what hardware/platform you use.     Since Android uses the Linux-kernel at this level, it is more or less   possible to use whatever filesystem the Linux-kernel supports.     But since most phones use some kind of nand flash, it is safe to assume   that they use YAFFS.     But please note that if some vendor wants to sell a Android netbook (with a   harddrive), they could use ext3 or something like that.
FIO39-C.   Do not alternately input and output from a stream without an intervening   flush or positioning call? 
FIO40-C.   Reset strings on fgets() or fgetws() failure? 
FIO41-C.   Do not call getc(), putc(), getwc(), or putwc() with a stream argument that   has side effects? 
FIO42-C.   Close files when they are no longer needed? 
FIO44-C.   Only use values for fsetpos() that are returned from fgetpos()? 
FIO45-C.   Avoid TOCTOU race conditions while accessing files? 
FIO46-C.   Do not access a closed file? 
FIO47-C.   Use valid format stringsApplicableUniversal
RecommendationsAndroid app development applicable?Comments
ENV01-C.   Do not make assumptions about the size of an environment variableApplicable 
ENV02-C.   Beware of multiple environment variables with the same effective nameApplicable 
ENV03-C.   Sanitize the environment when invoking external programsApplicable 
RulesAndroid app development applicable?Comments
ENV30-C.   Do not modify the object referenced by the return value of certain functionsApplicable 
ENV31-C.   Do not rely on an environment pointer following an operation that may   invalidate itApplicable 
ENV32-C.   All exit handlers must return normallyApplicable 
ENV33-C.   Do not call system()Applicable 
ENV34-C.   Do not store pointers returned by certain functionsApplicable 
RecommendationsAndroid app development applicable?Comments
SIG00-C.   Mask signals handled by noninterruptible signal handlersApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
SIG01-C.   Understand implementation-specific details regarding signal handler   persistenceApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
SIG02-C.   Avoid using signals to implement normal functionalityApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
RulesAndroid app development applicable?Comments
SIG30-C.   Call only asynchronous-safe functions within signal handlersApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
SIG31-C.   Do not access shared objects in signal handlersApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
SIG34-C.   Do not call signal() from within interruptible signal handlersApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
SIG35-C.   Do not return from a computational exception signal handlerApplicableSigAction may solve these   problems. If Android supports SigAction, these rules/recommendations may not   be needed.      http://stackoverflow.com/questions/7245550/android-app-restarts-automatically-after-a-crash
RecommendationsAndroid app development applicable?Comments
ERR00-C.   Adopt and implement a consistent and comprehensive error-handling policyApplicable 
ERR01-C.   Use ferror() rather than errno to check for FILE stream errorsApplicable 
ERR02-C.   Avoid in-band error indicatorsApplicable 
ERR03-C.   Use runtime-constraint handlers when calling the bounds-checking interfacesApplicable 
ERR04-C.   Choose an appropriate termination strategyApplicable 
ERR05-C.   Application-independent code should provide error detection without dictating   error handlingApplicable 
ERR06-C.   Understand the termination behavior of assert() and abort()Applicable 
ERR07-C.   Prefer functions that support error checking over equivalent functions that   don'tApplicable 
RulesAndroid app development applicable?Comments
ERR30-C.   Set errno to zero before calling a library function known to set errno, and   check errno only after the function returns a value indicating failureApplicable 
ERR32-C.   Do not rely on indeterminate values of errnoApplicable 
ERR33-C.   Detect and handle standard library errorsApplicable 
RecommendationsAndroid app development applicable?Comments
API00-C.   Functions should validate their parametersApplicable 
API01-C.   Avoid laying out strings in memory directly before sensitive data? 
API02-C.   Functions that read or write to or from an array should take an argument to   specify the source or target sizeApplicable Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
API03-C.   Create consistent interfaces and capabilities across related functionsApplicable 
API04-C.   Provide a consistent and usable error-checking mechanismApplicable 
API05-C.   Use conformant array parametersApplicable Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
API07-C.   Enforce type safetyApplicable 
API08-C.   Avoid parameter names in a function prototypeApplicable 
API09-C.   Compatible values should have the same type? 
RecommendationsAndroid app development applicable?Comments
CON00-C.   Avoid race conditions with multiple threads?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON01-C.   Acquire and release synchronization primitives in the same module, at the   same level of abstraction?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON02-C.   Do not use volatile as a synchronization primitive?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON03-C.   Ensure visibility when accessing shared variables?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON04-C.   Join or detach threads even if their exit status is unimportant?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON05-C.   Do not perform operations that can block while holding a lock?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON06-C.   Ensure that every mutex outlives the data it protects?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON07-C.   Ensure that compound operations on shared variables are atomic?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON08-C.   Do not assume that a group of calls to independently atomic methods is atomic?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON09-C.   Avoid the ABA problem when using lock-free algorithms?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
RulesAndroid app development applicable?Comments
CON30-C.   Clean up thread-specific storage?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON31-C.   Do not destroy a mutex while it is locked?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON32-C.   Prevent data races when accessing bit-fields from multiple threads?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON33-C.   Avoid race conditions when using library functions?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON34-C.   Declare objects shared between threads with appropriate storage durations?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON35-C.   Avoid deadlock by locking in a predefined order?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON36-C.   Wrap functions that can spuriously wake up in a loop?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON37-C.   Do not call signal() in a multithreaded program?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON38-C.   Preserve thread safety and liveness when using condition variables?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON39-C.   Do not join or detach a thread that was previously joined or detached?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON40-C.   Do not refer to an atomic variable twice in an expression?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
CON41-C.   Wrap functions that can fail spuriously in a loop?CON concurrency: Need to look into Android, does it support C11? Look at   specifics of Android. Maybe POSIX threads, not C11 threads.
RecommendationsAndroid app development applicable?Comments
MSC00-C.   Compile cleanly at high warning levelsApplicable 
MSC01-C.   Strive for logical completenessApplicable 
MSC04-C.   Use comments consistently and in a readable fashionApplicable 
MSC05-C.   Do not manipulate time_t typed values directlyApplicable 
MSC06-C.   Beware of compiler optimizationsApplicable 
MSC07-C.   Detect and remove dead codeApplicable 
MSC09-C.   Character encoding: Use subset of ASCII for safetyApplicable 
MSC10-C.   Character encoding: UTF8-related issuesApplicable 
MSC11-C.   Incorporate diagnostic tests using assertionsApplicable 
MSC12-C.   Detect and remove code that has no effectApplicable 
MSC13-C.   Detect and remove unused valuesApplicable 
MSC14-C.   Do not introduce unnecessary platform dependenciesApplicable 
MSC15-C.   Do not depend on undefined behaviorApplicable 
MSC17-C.   Finish every set of statements associated with a case label with a break   statementApplicable 
MSC18-C.   Be careful while handling sensitive data, such as passwords, in program codeApplicable 
MSC19-C.   For functions that return an array, prefer returning an empty array over a null valueApplicable Arrays: Need examination of Android support. (gcc support of arrays partial). Note native code array issues different with ART than with Dalvik: http://developer.android.com/guide/practices/verifying-apps-art.html#JNI_Issues 
MSC20-C.   Do not use a switch statement to transfer control into a complex blockApplicable 
MSC21-C.   Use robust loop termination conditionsApplicable 
MSC22-C.   Use the setjmp(), longjmp() facility securelyApplicable 
MSC23-C.   Beware of vendor-specific library and language differencesApplicable 
MSC24-C.   Do not use deprecated or obsolescent functionsApplicable 
RulesAndroid app development applicable?Comments
MSC30-C.   Do not use the rand() function for generating pseudorandom numbersApplicable 
MSC32-C.   Properly seed pseudorandom number generatorsApplicable 
MSC33-C.   Do not pass invalid data to the asctime() functionApplicable 
MSC37-C.   Ensure that control never reaches the end of a non-void functionApplicable 
MSC38-C.   Do not treat a predefined identifier as an object if it might only be   implemented as a macroApplicable 
MSC39-C.   Do not call va_arg() on a va_list that has an indeterminate valueApplicable 
MSC40-C.   Do not violate constraintsApplicable 
RecommendationsAndroid app development applicable?Comments
POS01-C.   Check for the existence of links when dealing with files? 
POS02-C.   Follow the principle of least privilegeApplicable 
POS04-C.   Avoid using PTHREAD_MUTEX_NORMAL type mutex locks? 
POS05-C.   Limit access to files by creating a jail? 
RulesAndroid app development applicable?Comments
POS30-C.   Use the readlink() function properly? 
POS33-C.   Do not use vfork()? 
POS34-C.   Do not call putenv() with a pointer to an automatic variable as the argument? 
POS35-C.   Avoid race conditions while checking for the existence of a symbolic link?Can apps get root? Can they run a shell? These rules/guidelines are not   meant to address rooted devices (different OS than standard Android)
POS36-C.   Observe correct revocation order while relinquishing privileges?Can apps get root? Can they run a shell? These rules/guidelines are not   meant to address rooted devices (different OS than standard Android)
POS37-C.   Ensure that privilege relinquishment is successful?Can apps get root? Can they run a shell? These rules/guidelines are not   meant to address rooted devices (different OS than standard Android)
POS38-C.   Beware of race conditions when using fork and file descriptors? 
POS39-C.   Use the correct byte ordering when transferring data between systems? 
POS44-C.   Do not use signals to terminate threads?Further investigation needed, specific to SigAction
POS47-C.   Do not use threads that can be canceled asynchronously? 
POS48-C.   Do not unlock or destroy another POSIX thread's mutex? 
POS49-C.   When data must be accessed by multiple threads, provide a mutex and guarantee   no adjacent data is also accessed? Look into Android specifics for   this, regarding "guarantee no adjacent data is accessed".
POS50-C.   Declare objects shared between POSIX threads with appropriate storage   durations? 
POS51-C.   Avoid deadlock with POSIX threads by locking in predefined order? 
POS52-C.   Do not perform operations that can block while holding a POSIX lock? 
POS53-C.   Do not use more than one mutex for concurrent waiting operations on a   condition variable? 
POS54-C.   Detect and handle POSIX library errors? 
RecommendationsAndroid app development applicable?Comments
WIN00-C.   Be specific when dynamically loading librariesNot applicableAndroid apps are not used in a Microsoft environment
WIN01-C.   Do not forcibly terminate executionNot applicableAndroid apps are not used in a Microsoft environment
WIN02-C.   Restrict privileges when spawning child processesNot applicableAndroid apps are not used in a Microsoft environment
WIN03-C.   Understand HANDLE inheritanceNot applicableAndroid apps are not used in a Microsoft environment
WIN04-C.   Consider encrypting function pointersNot applicableAndroid apps are not used in a Microsoft environment
RulesAndroid app development applicable?Comments
WIN30-C.   Properly pair allocation and deallocation functionsNot applicableAndroid apps are not used in a Microsoft environment

 

 

  • No labels