|
Home About Us A-Z Index Search * Contact Us Register Login Press ShopThe Open Brand -- Problem Reporting and Interpretations System |
Problem Report 0208 Details
Show help | Quick Search | Submit a Test Suite Support Request | Click here to view your privileges
This page provides all information on Problem Report 0208.
Report 0208 Actions
Problem Report Number 0208 Submitter's Classification Test Suite problem State Resolved Resolution Test Suite Deficiency (TSD) Problem Resolution ID TSD.X.0208 Raised 1995-05-02 08:00 Updated 2003-03-13 08:00 Published 1995-05-04 08:00 Product Standard Internationalised System Calls and Libraries (XPG4) Certification Program The Open Brand certification program Test Suite VSX4 version 4.3.4 Test Identification ANSI.hdr/misc/string 32, 38 Problem Summary TSD4.208 These tests make one crucial mistake which makes their results unpredictable. The code basically does: char s1[5]; char *s2; int arg1 = 0; int arg2 = 0; char *var1 = 0; char *var2 = 0; s2 = "test"; (v... Problem Text
These tests make one crucial mistake which makes their results
unpredictable. The code basically does:
char s1[5];
char *s2;
int arg1 = 0;
int arg2 = 0;
char *var1 = 0;
char *var2 = 0;
s2 = "test";
(void) strcat(var1 = (arg1++, s1),var2 = (arg2++, s2))[0] ;
If we concentrate on only the strcat() operation, this can be simplified
to:
strcat(s1, s2);
telling strcat() to append the string pointed to by s1 with the string
pointed to by s2. The problem is that s1 was never initialized.
Section 3.5.7 of the ANSI C standard states:
"If an object that has automatic storage duration is not
initialized explicitly, its value is indeterminate."
The contents of s1 are unpredictable. The strcat() operation will
attempt to find the end of the string pointed to by s1 but this may not
be within the five bytes allocated for s1. The concatenation may take
place outside of the storage allocated for s1, possibly overlaying other
variables, and producing unpredictable results.
The target string of a strcat() or strncat() operation should never be
uninitialized. These tests should be modified so that the target string
is either initialized or data is copied into it via strcpy() prior to
the concatenation operation.Test Output
/tset/ANSI.hdr/misc/string/T.string 32.Failed
Test Description:
If the header file contains a macro definition for strcat(), it
evaluates its arguments only once, fully protected by parentheses when
necessary, and protects its return value with parentheses.
Posix Ref: Component STRCAT Assertion 8.1-03(C)
Test Strategy:
INVOKE macro with an increment and assignment in each argument.
CAST subscripted macro to (void) - this verifies the return value is
parenthesised.
VERIFY that increments occurred once and assignments gave correct
values.
Test Information:
Feature test macros: -D_XOPEN_SOURCE
Compiler or run-time messages or results:
Arg 2 of strcat not protected by parentheses
.
.
.
/tset/ANSI.hdr/misc/string/T.string 38.Failed
Test Description:
If the header file contains a macro definition for strncat(), it
evaluates its arguments only once, fully protected by parentheses when
necessary, and protects its return value with parentheses.
Posix Ref: Component STRNCAT Assertion 8.1-03(C)
Test Strategy:
INVOKE macro with an increment and assignment in each argument.
CAST subscripted macro to (void) - this verifies the return value is
parenthesised.
VERIFY that increments occurred once and assignments gave correct
values.
Test Information:
Feature test macros: -D_XOPEN_SOURCE
Compiler or run-time messages or results:
Arg 2 of strncat not protected by parentheses
.
.
.Review Information
Review Type TSMA Review Start Date null Completed null Status Complete Review Recommendation No Resolution Given Review Response
This is accepted as a fault in the test suite and it is recommended that
this is treated as a Test Suite Deficiency.
Review Type SA Review Start Date null Completed null Status Complete Review Resolution Test Suite Deficiency (TSD) Review Conclusion
This is an agreed Test Suite Deficiency.
Problem Reporting System Options:
- View Report 0208
- List All PRs
- Search Reports
- Email the System Administrator
- View the The Open Brand Interpretations Database User Manual
Contact the Certification Authority