svn commit: r206267 - head/lib/libc/net

Hajimu UMEMOTO ume at FreeBSD.org
Tue Apr 6 12:33:05 UTC 2010


Author: ume
Date: Tue Apr  6 12:33:05 2010
New Revision: 206267
URL: http://svn.freebsd.org/changeset/base/206267

Log:
  Use the stored length value instead of calculating it by strlen().

Modified:
  head/lib/libc/net/getservent.c

Modified: head/lib/libc/net/getservent.c
==============================================================================
--- head/lib/libc/net/getservent.c	Tue Apr  6 12:28:08 2010	(r206266)
+++ head/lib/libc/net/getservent.c	Tue Apr  6 12:33:05 2010	(r206267)
@@ -489,11 +489,9 @@ static int
 db_servent(void *retval, void *mdata, va_list ap)
 {
 	char buf[BUFSIZ];
-	DBT key, data;
+	DBT key, data, *result;
 	DB *db;
 
-	char *resultbuf;
-
 	struct db_state *st;
 	int rv;
 	int stayopen;
@@ -565,7 +563,7 @@ db_servent(void *retval, void *mdata, va
 				rv = NS_NOTFOUND;
 				goto db_fin;
 			}
-			resultbuf = key.data;
+			result = &key;
 			break;
 		case nss_lt_id:
 			key.data = buf;
@@ -582,7 +580,7 @@ db_servent(void *retval, void *mdata, va
 				rv = NS_NOTFOUND;
 				goto db_fin;
 			}
-			resultbuf = key.data;
+			result = &key;
 			break;
 		case nss_lt_all:
 			key.data = buf;
@@ -594,12 +592,12 @@ db_servent(void *retval, void *mdata, va
 				rv = NS_NOTFOUND;
 				goto db_fin;
 			}
-			resultbuf = data.data;
+			result = &data;
 			break;
 		}
 
-		rv = parse_result(serv, buffer, bufsize, resultbuf,
-		    strlen(resultbuf), errnop);
+		rv = parse_result(serv, buffer, bufsize, result->data,
+		    result->size - 1, errnop);
 
 	} while (!(rv & NS_TERMINATE) && how == nss_lt_all);
 


More information about the svn-src-head mailing list