/* * bogon -- misuse a strncpy. * * Copyright (C) 2004 David Collier-Brown * * This program is free software; you can redistribute it and/or modify * it under the terms of your choice of the GNU Lesser (Library) General * Public License or the Sun Common Development and Distribution License. */ #include #include /* #define BUFFERSIZE 25 */ #define BUFFERSIZE 4 int main() { char *src = "a string of more than five characters.", dest[BUFFERSIZE]; (void) strncpy(dest, src, 15); (void) strncat(dest, src, 15); (void) snprintf(dest, sizeof(dest), "This will be truncated......\n"); (void) fprintf(stderr, "Bogon completed sucessfully\n"); return 0; }