basename.c (1250db81390606572908abd88d78c1f2fa5a1832) basename.c (ff5f0dbc4116ecea47fcacf10db7f6807b6d063b)
1/* $OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */
2/* $FreeBSD$ */
3
4/*
5 * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

61 return(bname);
62 }
63
64 /* Find the start of the base */
65 startp = endp;
66 while (startp > path && *(startp - 1) != '/')
67 startp--;
68
1/* $OpenBSD: basename.c,v 1.4 1999/05/30 17:10:30 espie Exp $ */
2/* $FreeBSD$ */
3
4/*
5 * Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

61 return(bname);
62 }
63
64 /* Find the start of the base */
65 startp = endp;
66 while (startp > path && *(startp - 1) != '/')
67 startp--;
68
69 if (endp - startp + 1 > sizeof(bname)) {
69 if (endp - startp + 2 > sizeof(bname)) {
70 errno = ENAMETOOLONG;
71 return(NULL);
72 }
73 (void)strncpy(bname, startp, endp - startp + 1);
74 bname[endp - startp + 1] = '\0';
75 return(bname);
76}
70 errno = ENAMETOOLONG;
71 return(NULL);
72 }
73 (void)strncpy(bname, startp, endp - startp + 1);
74 bname[endp - startp + 1] = '\0';
75 return(bname);
76}