fwrite.c (cfe30d02adda7c3b5c76156ac52d50d8cab325d9) fwrite.c (db081af109f6a64a357c9c52a48a54ee61036178)
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 51 unchanged lines hidden (view full) ---

60 * ANSI and SUSv2 require a return value of 0 if size or count are 0.
61 */
62 if ((count == 0) || (size == 0))
63 return (0);
64
65 /*
66 * Check for integer overflow. As an optimization, first check that
67 * at least one of {count, size} is at least 2^16, since if both
1/*-
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Chris Torek.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 51 unchanged lines hidden (view full) ---

60 * ANSI and SUSv2 require a return value of 0 if size or count are 0.
61 */
62 if ((count == 0) || (size == 0))
63 return (0);
64
65 /*
66 * Check for integer overflow. As an optimization, first check that
67 * at least one of {count, size} is at least 2^16, since if both
68 * values are less than that, their product can't possible overflow
68 * values are less than that, their product can't possibly overflow
69 * (size_t is always at least 32 bits on FreeBSD).
70 */
71 if (((count | size) > 0xFFFF) &&
72 (count > SIZE_MAX / size)) {
73 errno = EINVAL;
74 fp->_flags |= __SERR;
75 return (0);
76 }

--- 20 unchanged lines hidden ---
69 * (size_t is always at least 32 bits on FreeBSD).
70 */
71 if (((count | size) > 0xFFFF) &&
72 (count > SIZE_MAX / size)) {
73 errno = EINVAL;
74 fp->_flags |= __SERR;
75 return (0);
76 }

--- 20 unchanged lines hidden ---