On Fri, Apr 13, 2007 at 04:02:37PM +0900, Simon Horman wrote: > If for some reason the file being scanned is malformed, or > overflows one of the feilds for some reason, scanf will neither > return EOF nor fill in all of its parameters correctly. In the > case that I observed this resulted in an endless loop. > > This simple fix just bails out in this case. > Perhaps an error message is in order?
yes, /proc might change. perhaps sth like: for( ;; ) { c=fscanf(...); if( c == EOF ) break; else if( c != 13 ) } besides, having such a large fscanf in a while test looks ugly. > > Index: heartbeat-ipv6addr/resources/OCF/IPv6addr.c > =================================================================== > --- heartbeat-ipv6addr.orig/resources/OCF/IPv6addr.c 2007-04-13 > 15:51:04.000000000 +0900 > +++ heartbeat-ipv6addr/resources/OCF/IPv6addr.c 2007-04-13 > 15:52:30.000000000 +0900 > @@ -448,7 +448,7 @@ > while ( fscanf(f,"%4s%4s%4s%4s%4s%4s%4s%4s %02x %02x %02x %02x %20s\n", > addr6p[0], addr6p[1], addr6p[2], addr6p[3], > addr6p[4], addr6p[5], addr6p[6], addr6p[7], > - &if_idx, &plen, &scope, &dad_status, devname) != EOF){ > + &if_idx, &plen, &scope, &dad_status, devname) == 13){ > > int i; > int n; > > -- > > -- > Horms > H: http://www.vergenet.net/~horms/ > W: http://www.valinux.co.jp/en/ > > _______________________________________________________ > Linux-HA-Dev: [EMAIL PROTECTED] > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev > Home Page: http://linux-ha.org/ -- Dejan _______________________________________________________ Linux-HA-Dev: [EMAIL PROTECTED] http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev Home Page: http://linux-ha.org/