dirname.c (1250db81390606572908abd88d78c1f2fa5a1832) | dirname.c (ff5f0dbc4116ecea47fcacf10db7f6807b6d063b) |
---|---|
1/* $OpenBSD: dirname.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 --- 55 unchanged lines hidden (view full) --- 64 (void)strcpy(bname, *endp == '/' ? "/" : "."); 65 return(bname); 66 } else { 67 do { 68 endp--; 69 } while (endp > path && *endp == '/'); 70 } 71 | 1/* $OpenBSD: dirname.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 --- 55 unchanged lines hidden (view full) --- 64 (void)strcpy(bname, *endp == '/' ? "/" : "."); 65 return(bname); 66 } else { 67 do { 68 endp--; 69 } while (endp > path && *endp == '/'); 70 } 71 |
72 if (endp - path + 1 > sizeof(bname)) { | 72 if (endp - path + 2 > sizeof(bname)) { |
73 errno = ENAMETOOLONG; 74 return(NULL); 75 } 76 (void)strncpy(bname, path, endp - path + 1); 77 bname[endp - path + 1] = '\0'; 78 return(bname); 79} | 73 errno = ENAMETOOLONG; 74 return(NULL); 75 } 76 (void)strncpy(bname, path, endp - path + 1); 77 bname[endp - path + 1] = '\0'; 78 return(bname); 79} |