misc.c (146998) | misc.c (147001) |
---|---|
1/* 2 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include "includes.h" | 1/* 2 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 9 unchanged lines hidden (view full) --- 18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 */ 24 25#include "includes.h" |
26RCSID("$OpenBSD: misc.c,v 1.28 2005/03/01 10:09:52 djm Exp $"); | 26RCSID("$OpenBSD: misc.c,v 1.29 2005/03/10 22:01:05 deraadt Exp $"); |
27 28#include "misc.h" 29#include "log.h" 30#include "xmalloc.h" 31 32/* remove newline at end of string */ 33char * 34chop(char *s) --- 263 unchanged lines hidden (view full) --- 298 s++; 299 } else if ((s = strpbrk(s, ":/")) == NULL) 300 s = *cp + strlen(*cp); /* skip to end (see first case below) */ 301 302 switch (*s) { 303 case '\0': 304 *cp = NULL; /* no more fields*/ 305 break; | 27 28#include "misc.h" 29#include "log.h" 30#include "xmalloc.h" 31 32/* remove newline at end of string */ 33char * 34chop(char *s) --- 263 unchanged lines hidden (view full) --- 298 s++; 299 } else if ((s = strpbrk(s, ":/")) == NULL) 300 s = *cp + strlen(*cp); /* skip to end (see first case below) */ 301 302 switch (*s) { 303 case '\0': 304 *cp = NULL; /* no more fields*/ 305 break; |
306 | 306 |
307 case ':': 308 case '/': 309 *s = '\0'; /* terminate */ 310 *cp = s + 1; 311 break; | 307 case ':': 308 case '/': 309 *s = '\0'; /* terminate */ 310 *cp = s + 1; 311 break; |
312 | 312 |
313 default: 314 return NULL; 315 } 316 317 return old; 318} 319 320char * --- 65 unchanged lines hidden (view full) --- 386 while (fgets(buf, bufsz, f) != NULL) { 387 (*lineno)++; 388 if (buf[strlen(buf) - 1] == '\n' || feof(f)) { 389 return 0; 390 } else { 391 debug("%s: %s line %lu exceeds size limit", __func__, 392 filename, *lineno); 393 /* discard remainder of line */ | 313 default: 314 return NULL; 315 } 316 317 return old; 318} 319 320char * --- 65 unchanged lines hidden (view full) --- 386 while (fgets(buf, bufsz, f) != NULL) { 387 (*lineno)++; 388 if (buf[strlen(buf) - 1] == '\n' || feof(f)) { 389 return 0; 390 } else { 391 debug("%s: %s line %lu exceeds size limit", __func__, 392 filename, *lineno); 393 /* discard remainder of line */ |
394 while(fgetc(f) != '\n' && !feof(f)) | 394 while (fgetc(f) != '\n' && !feof(f)) |
395 ; /* nothing */ 396 } 397 } 398 return -1; 399} | 395 ; /* nothing */ 396 } 397 } 398 return -1; 399} |