Home | History | Annotate | Download | only in tests

Lines Matching refs:str

54 // Input to a test is a zero-terminated string str with given length
55 // Accesses to the bytes to the left and to the right of str
57 void StrLenOOBTestTemplate(char *str, size_t length, OOBKind oob_kind) {
59 EXPECT_EQ(strlen(str), length);
61 EXPECT_EQ(length - 1, strlen(str + 1));
62 EXPECT_EQ(0U, strlen(str + length));
67 EXPECT_DEATH(Ident(strlen(str - 1)), LeftOOBReadMessage(oob_kind, 1));
68 EXPECT_DEATH(Ident(strlen(str - 5)), LeftOOBReadMessage(oob_kind, 5));
70 EXPECT_DEATH(Ident(strlen(str + length + 1)),
73 str[length] = 'a';
75 EXPECT_DEATH(Ident(strlen(str)), RightOOBReadMessage(oob_kind, 0));
76 EXPECT_DEATH(Ident(strlen(str + length)), RightOOBReadMessage(oob_kind, 0));
78 str[length] = 0;
113 char *str = MallocAndMemsetString(size);
115 Ident(strnlen(str - 1, 0));
116 Ident(strnlen(str, size));
117 Ident(strnlen(str + size - 1, 1));
118 str[size - 1] = '\0';
119 Ident(strnlen(str, 2 * size));
121 EXPECT_DEATH(Ident(strnlen(str - 1, 1)), LeftOOBReadMessage(1));
122 EXPECT_DEATH(Ident(strnlen(str + size, 1)), RightOOBReadMessage(0));
124 str[size - 1] = 'z';
125 EXPECT_DEATH(Ident(strnlen(str, size + 1)), RightOOBReadMessage(0));
126 free(str);
132 char *str = MallocAndMemsetString(size);
135 str[size - 1] = '\0';
136 new_str = strdup(str);
138 new_str = strdup(str + size - 1);
141 EXPECT_DEATH(Ident(strdup(str - 1)), LeftOOBReadMessage(1));
142 EXPECT_DEATH(Ident(strdup(str + size)), RightOOBReadMessage(0));
144 str[size - 1] = 'z';
145 EXPECT_DEATH(Ident(strdup(str)), RightOOBReadMessage(0));
146 free(str);
222 char *str = MallocAndMemsetString(size);
223 str[10] = 'q';
224 str[11] = '\0';
225 EXPECT_EQ(str, StrChr(str, 'z'));
226 EXPECT_EQ(str + 10, StrChr(str, 'q'));
227 EXPECT_EQ(NULL, StrChr(str, 'a'));
229 EXPECT_DEATH(Ident(StrChr(str - 1, 'z')), LeftOOBReadMessage(1));
230 EXPECT_DEATH(Ident(StrChr(str + size, 'z')), RightOOBReadMessage(0));
232 str[11] = 'z';
233 EXPECT_DEATH(Ident(StrChr(str, 'a')), RightOOBReadMessage(0));
234 free(str);
273 #if !defined(_WIN32) // no str[n]casecmp on Windows.
333 #if !defined(_WIN32) // no str[n]casecmp on Windows.
370 #if !defined(_WIN32) // no str[n]casecmp on Windows.
453 char *str = Ident((char*)malloc(size));
460 memset(str, 'z', size);
461 Ident(memcpy)(str + 1, str + 11, 10);
462 Ident(memcpy)(str, str, 0);
463 EXPECT_DEATH(Ident(memcpy)(str, str
464 EXPECT_DEATH(Ident(memcpy)(str + 14, str, 15), OverlapErrorMessage("memcpy"));
469 // EXPECT_DEATH(Ident(memcpy)(str + 20, str + 20, 1),
473 memset(str, 'z', size);
474 str[9] = '\0';
475 strcpy(str + 10, str);
476 EXPECT_DEATH(strcpy(str + 9, str), OverlapErrorMessage("strcpy"));
477 EXPECT_DEATH(strcpy(str, str + 4), OverlapErrorMessage("strcpy"));
478 strcpy(str, str + 5);
481 memset(str, 'z', size);
482 strncpy(str, str + 10, 10);
483 EXPECT_DEATH(strncpy(str, str + 9, 10), OverlapErrorMessage("strncpy"));
484 EXPECT_DEATH(strncpy(str + 9, str, 10), OverlapErrorMessage("strncpy"));
485 str[10] = '\0';
486 strncpy(str + 11, str, 20);
487 EXPECT_DEATH(strncpy(str + 10, str, 20), OverlapErrorMessage("strncpy"));
490 memset(str, 'z', size);
491 str[10] = '\0';
492 str[20] = '\0';
493 strcat(str, str + 10);
494 EXPECT_DEATH(strcat(str, str + 11), OverlapErrorMessage("strcat"));
495 str[10] = '\0';
496 strcat(str + 11, str);
497 EXPECT_DEATH(strcat(str, str + 9), OverlapErrorMessage("strcat"));
498 EXPECT_DEATH(strcat(str + 9, str), OverlapErrorMessage("strcat"));
499 EXPECT_DEATH(strcat(str + 10, str), OverlapErrorMessage("strcat"));
502 memset(str, 'z', size);
503 str[10] = '\0';
504 strncat(str, str + 10, 10); // from is empty
505 EXPECT_DEATH(strncat(str, str + 11, 10), OverlapErrorMessage("strncat"));
506 str[10] = '\0';
507 str[20] = '\0';
508 strncat(str + 5, str, 5);
509 str[10] = '\0';
510 EXPECT_DEATH(strncat(str + 5, str, 6), OverlapErrorMessage("strncat"));
511 EXPECT_DEATH(strncat(str, str + 9, 10), OverlapErrorMessage("strncat"));
513 free(str);