-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
arg_check.c
684 lines (634 loc) · 18.8 KB
/
arg_check.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
/*
* Functions for testing of string routines arguments.
*
* Copyright 2020 by Gray Watson
*
* This file is part of the dmalloc package.
*
* Permission to use, copy, modify, and distribute this software for
* any purpose and without fee is hereby granted, provided that the
* above copyright notice and this permission notice appear in all
* copies, and that the name of Gray Watson not be used in advertising
* or publicity pertaining to distribution of the document or software
* without specific, written prior permission.
*
* Gray Watson makes no representations about the suitability of the
* software described herein for any purpose. It is provided "as is"
* without express or implied warranty.
*
* The author may be contacted via https://dmalloc.com/
*/
/*
* This file contains functions to be used to verify the arguments of
* string functions. If enabled these can discover problems with
* heap-based strings (such as fence errors) much closer to the error.
*/
#define DMALLOC_DISABLE
#if HAVE_STRING_H
# include <string.h>
#endif
#if HAVE_STRINGS_H
# include <strings.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "conf.h"
#include "dmalloc.h"
#include "chunk.h"
#include "debug_tok.h"
#include "error.h"
#include "dmalloc_loc.h"
#include "arg_check.h"
/*
* Dummy function for checking strlen's arguments.
*/
static int loc_strlen(const char *file, const int line,
const char *func, const char *str)
{
int len = 0;
const char *str_p;
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, func, str, 0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in %s", func);
}
}
for (str_p = str; *str_p != '\0'; str_p++) {
len++;
}
return len;
}
#if HAVE_ATOI
/*
* Dummy function for checking atoi's arguments.
*/
int _dmalloc_atoi(const char *file, const int line, const char *str)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "atoi", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in atoi");
}
}
return atoi(str);
}
#endif /* HAVE_ATOI */
#if HAVE_ATOL
/*
* Dummy function for checking atol's arguments.
*/
long _dmalloc_atol(const char *file, const int line, const char *str)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "atol", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in atol");
}
}
return atol(str);
}
#endif /* HAVE_ATOL */
#if HAVE_BCMP
/*
* Dummy function for checking bcmp's arguments.
*/
int _dmalloc_bcmp(const char *file, const int line,
const void *b1, const void *b2, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "bcmp", b1,
0 /* not exact */, len))
|| (! dmalloc_verify_pnt(file, line, "bcmp", b2,
0 /* not exact */, len))) {
dmalloc_message("bad pointer argument found in bcmp");
}
}
return bcmp(b1, b2, len);
}
#endif /* HAVE_BCMP */
#if HAVE_BCOPY
/*
* Dummy function for checking bcopy's arguments.
*/
void _dmalloc_bcopy(const char *file, const int line,
const void *from, void *to, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "bcopy", from,
0 /* not exact */, len))
|| (! dmalloc_verify_pnt(file, line, "bcopy", to,
0 /* not exact */, len))) {
dmalloc_message("bad pointer argument found in bcopy");
}
}
bcopy(from, to, len);
}
#endif /* HAVE_BCOPY */
#if HAVE_BZERO
/*
* Dummy function for checking bzero's arguments.
*/
void _dmalloc_bzero(const char *file, const int line,
void *buf, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "bzero", buf,
0 /* not exact */, len)) {
dmalloc_message("bad pointer argument found in bzero");
}
}
bzero(buf, len);
}
#endif /* HAVE_BZERO */
#if HAVE_INDEX
/*
* Dummy function for checking index's arguments.
*/
char *_dmalloc_index(const char *file, const int line,
const char *str, const char ch)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "index", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in index");
}
}
return (char *)index(str, ch);
}
#endif /* HAVE_INDEX */
#if HAVE_MEMCCPY
/*
* Dummy function for checking memccpy's arguments.
*/
void *_dmalloc_memccpy(const char *file, const int line,
void *dest, const void *src, const int ch,
const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
const char *src_p;
int min_size;
/* so we have to figure out the max length of the buffer directly here */
for (src_p = (char *)src; src_p < (char *)src + len; src_p++) {
if (*src_p == ch) {
src_p++;
break;
}
}
min_size = src_p - (char *)src;
/* maybe len maybe first ch */
if ((! dmalloc_verify_pnt(file, line, "memccpy", dest,
0 /* not exact */, min_size))
|| (! dmalloc_verify_pnt(file, line, "memccpy", src,
0 /* not exact */, min_size))) {
dmalloc_message("bad pointer argument found in memccpy");
}
}
return (void *)memccpy(dest, src, ch, len);
}
#endif /* HAVE_MEMCCPY */
#if HAVE_MEMCHR
/*
* Dummy function for checking memchr's arguments.
*/
void *_dmalloc_memchr(const char *file, const int line,
const void *s1, const int ch, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "memchr", s1,
0 /* not exact */, len)) {
dmalloc_message("bad pointer argument found in memchr");
}
}
return (void *)memchr(s1, ch, len);
}
#endif /* HAVE_MEMCHR */
#if HAVE_MEMCMP
/*
* Dummy function for checking memcmp's arguments.
*/
int _dmalloc_memcmp(const char *file, const int line,
const void *b1, const void *b2, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "memcmp", b1,
0 /* not exact */, len))
|| (! dmalloc_verify_pnt(file, line, "memcmp", b2,
0 /* not exact */, len))) {
dmalloc_message("bad pointer argument found in memcmp");
}
}
return memcmp(b1, b2, len);
}
#endif /* HAVE_MEMCMP */
#if HAVE_MEMCPY
/*
* Dummy function for checking memcpy's arguments.
*/
void *_dmalloc_memcpy(const char *file, const int line,
void *to, const void *from, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "memcpy", to,
0 /* not exact */, len))
|| (! dmalloc_verify_pnt(file, line, "memcpy", from,
0 /* not exact */, len))) {
dmalloc_message("bad pointer argument found in memcpy");
}
#if HAVE_MEMMOVE
/*
* If memmove exists, dump out a warning if memcpy is being used
* for overlapping memory segments.
*/
if (((char *)from < (char *)to && (char *)from + len > (char *)to)
|| ((char *)to < (char *)from && (char *)to + len > (char *)from)) {
dmalloc_message("%s:%d: WARNING: memory overlap in memcpy, should use memmove",
file, line);
}
#endif
}
return (void *)memcpy(to, from, len);
}
#endif /* HAVE_MEMCPY */
#if HAVE_MEMMOVE
/*
* Dummy function for checking memmove's arguments.
*/
void *_dmalloc_memmove(const char *file, const int line,
void *to, const void *from, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "memmove", to,
0 /* not exact */, len))
|| (! dmalloc_verify_pnt(file, line, "memmove", from,
0 /* not exact */, len))) {
dmalloc_message("bad pointer argument found in memmove");
}
}
return (void *)memmove(to, from, len);
}
#endif /* HAVE_MEMMOVE */
#if HAVE_MEMSET
/*
* Dummy function for checking memset's arguments.
*/
void *_dmalloc_memset(const char *file, const int line, void *buf,
const int ch, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "memset", buf,
0 /* not exact */, len)) {
dmalloc_message("bad pointer argument found in memset");
}
}
return (void *)memset(buf, ch, len);
}
#endif /* HAVE_MEMSET */
#if HAVE_RINDEX
/*
* Dummy function for checking rindex's arguments.
*/
char *_dmalloc_rindex(const char *file, const int line,
const char *str, const char ch)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "rindex", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in rindex");
}
}
return (char *)rindex(str, ch);
}
#endif /* HAVE_RINDEX */
#if HAVE_STRCASECMP
/*
* Dummy function for checking strcasecmp's arguments.
*/
int _dmalloc_strcasecmp(const char *file, const int line,
const char *s1, const char *s2)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strcasecmp", s1,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strcasecmp", s2,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strcasecmp");
}
}
return strcasecmp(s1, s2);
}
#endif /* HAVE_STRCASECMP */
#if HAVE_STRCAT
/*
* Dummy function for checking strcat's arguments.
*/
char *_dmalloc_strcat(const char *file, const int line,
char *to, const char *from)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strcat", to,
0 /* not exact */,
loc_strlen(file, line, "strcat", to)
+ loc_strlen(file, line, "strcat", from) + 1))
|| (! dmalloc_verify_pnt(file, line, "strcat", from,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strcat");
}
}
return (char *)strcat(to, from);
}
#endif /* HAVE_STRCAT */
#if HAVE_STRCHR
/*
* Dummy function for checking strchr's arguments.
*/
char *_dmalloc_strchr(const char *file, const int line,
const char *str, const int ch)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "strchr", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in strchr");
}
}
return (char *)strchr(str, ch);
}
#endif /* HAVE_STRCHR */
#if HAVE_STRCMP
/*
* Dummy function for checking strcmp's arguments.
*/
int _dmalloc_strcmp(const char *file, const int line,
const char *s1, const char *s2)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strcmp", s1,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strcmp", s2,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strcmp");
}
}
return strcmp(s1, s2);
}
#endif /* HAVE_STRCMP */
#if HAVE_STRCPY
/*
* Dummy function for checking strcpy's arguments.
*/
char *_dmalloc_strcpy(const char *file, const int line,
char *to, const char *from)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strcpy", to,
0 /* not exact */,
loc_strlen(file, line, "strcpy", from) + 1))
|| (! dmalloc_verify_pnt(file, line, "strcpy", from,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strcpy");
}
}
return (char *)strcpy(to, from);
}
#endif /* HAVE_STRCPY */
#if HAVE_STRCSPN
/*
* Dummy function for checking strcspn's arguments.
*/
int _dmalloc_strcspn(const char *file, const int line,
const char *str, const char *list)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strcspn", str,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strcspn", list,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strcspn");
}
}
return strcspn(str, list);
}
#endif /* HAVE_STRCSPN */
#if HAVE_STRLEN
/*
* Dummy function for checking strlen's arguments.
*/
DMALLOC_SIZE _dmalloc_strlen(const char *file, const int line,
const char *str)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "strlen", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in strlen");
}
}
return loc_strlen(file, line, "strlen", str);
}
#endif
#if HAVE_STRNCASECMP
/*
* Dummy function for checking strncasecmp's arguments.
*/
int _dmalloc_strncasecmp(const char *file, const int line,
const char *s1, const char *s2,
const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
const char *s1_p, *s2_p;
int min_size;
/* we go through both pointers up to the length characters */
for (s1_p = s1, s2_p = s2; s1_p < s1 + len; s1_p++, s2_p++) {
if (*s1_p == '\0' || *s2_p == '\0') {
s1_p++;
break;
}
}
min_size = s1_p - s1;
if ((! dmalloc_verify_pnt(file, line, "strncasecmp", s1,
0 /* not exact */, min_size))
|| (! dmalloc_verify_pnt(file, line, "strncasecmp", s2,
0 /* not exact */, min_size))) {
dmalloc_message("bad pointer argument found in strncasecmp");
}
}
return strncasecmp(s1, s2, len);
}
#endif /* HAVE_STRNCASECMP */
#if HAVE_STRNCAT
/*
* Dummy function for checking strncat's arguments.
*/
char *_dmalloc_strncat(const char *file, const int line,
char *to, const char *from, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
const char *from_p;
int min_size;
/* so we have to figure out the max length of the buffers directly here */
for (from_p = from; from_p < from + len; from_p++) {
if (*from_p == '\0') {
/* no need to do ++ here because we +1 for the \0 anyway */
break;
}
}
min_size = from_p - from;
/* either len or nullc */
if ((! dmalloc_verify_pnt(file, line, "strncat", to,
0 /* not exact */,
loc_strlen(file, line, "strncat", to) + min_size
+ 1))
|| (! dmalloc_verify_pnt(file, line, "strncat", from,
0 /* not exact */, min_size))) {
dmalloc_message("bad pointer argument found in strncat");
}
}
return (char *)strncat(to, from, len);
}
#endif /* HAVE_STRNCAT */
#if HAVE_STRNCMP
/*
* Dummy function for checking strncmp's arguments.
*/
int _dmalloc_strncmp(const char *file, const int line,
const char *s1, const char *s2,
const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
const char *s1_p, *s2_p;
int min_size;
/* so we have to figure out the max length of the buffers directly here */
for (s1_p = s1, s2_p = s2; s1_p < s1 + len; s1_p++, s2_p++) {
if (*s1_p == '\0' || *s2_p == '\0') {
s1_p++;
break;
}
}
min_size = s1_p - s1;
/* either len or nullc */
if ((! dmalloc_verify_pnt(file, line, "strncmp", s1,
0 /* not exact */, min_size))
|| (! dmalloc_verify_pnt(file, line, "strncmp", s2,
0 /* not exact */, min_size))) {
dmalloc_message("bad pointer argument found in strncmp");
}
}
return strncmp(s1, s2, len);
}
#endif /* HAVE_STRNCMP */
#if HAVE_STRNCPY
/*
* Dummy function for checking strncpy's arguments.
*/
char *_dmalloc_strncpy(const char *file, const int line,
char *to, const char *from, const DMALLOC_SIZE len)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
const char *from_p;
int min_size;
/* so we have to figure out the max length of the buffers directly here */
for (from_p = from; from_p < from + len; from_p++) {
if (*from_p == '\0') {
from_p++;
break;
}
}
min_size = from_p - from;
/* len or until nullc */
if ((! dmalloc_verify_pnt(file, line, "strncpy", to,
0 /* not exact */, min_size))
|| (! dmalloc_verify_pnt(file, line, "strncpy", from,
0 /* not exact */, min_size))) {
dmalloc_message("bad pointer argument found in strncpy");
}
}
return (char *)strncpy(to, from, len);
}
#endif /* HAVE_STRNCPY */
#if HAVE_STRPBRK
/*
* Dummy function for checking strpbrk's arguments.
*/
char *_dmalloc_strpbrk(const char *file, const int line,
const char *str, const char *list)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strpbrk", str,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strpbrk", list,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strpbrk");
}
}
return (char *)strpbrk(str, list);
}
#endif /* HAVE_STRPBRK */
#if HAVE_STRRCHR
/*
* Dummy function for checking strrchr's arguments.
*/
char *_dmalloc_strrchr(const char *file, const int line,
const char *str, const int ch)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if (! dmalloc_verify_pnt(file, line, "strrchr", str,
0 /* not exact */, -1)) {
dmalloc_message("bad pointer argument found in strrchr");
}
}
return (char *)strrchr(str, ch);
}
#endif /* HAVE_STRRCHR */
#if HAVE_STRSPN
/*
* Dummy function for checking strspn's arguments.
*/
int _dmalloc_strspn(const char *file, const int line,
const char *str, const char *list)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strspn", str,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strspn", list,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strspn");
}
}
return strspn(str, list);
}
#endif /* HAVE_STRSPN */
#if HAVE_STRSTR
/*
* Dummy function for checking strstr's arguments.
*/
char *_dmalloc_strstr(const char *file, const int line,
const char *str, const char *pat)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((! dmalloc_verify_pnt(file, line, "strstr", str,
0 /* not exact */, -1))
|| (! dmalloc_verify_pnt(file, line, "strstr", pat,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strstr");
}
}
return (char *)strstr(str, pat);
}
#endif /* HAVE_STRSTR */
#if HAVE_STRTOK
/*
* Dummy function for checking strtok's arguments.
*/
char *_dmalloc_strtok(const char *file, const int line,
char *str, const char *sep)
{
if (BIT_IS_SET(_dmalloc_flags, DMALLOC_DEBUG_CHECK_FUNCS)) {
if ((str != NULL
&& (! dmalloc_verify_pnt(file, line, "strtok", str,
0 /* not exact */, -1)))
|| (! dmalloc_verify_pnt(file, line, "strtok", sep,
0 /* not exact */, -1))) {
dmalloc_message("bad pointer argument found in strtok");
}
}
return (char *)strtok(str, sep);
}
#endif /* HAVE_STRTOK */