Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MFC r253380,253413: name passed into __setenv is not necessarily NUL-…

…terminated

Approved by:	re (kib)
  • Loading branch information...
commit 7d0241f558f7292bc6c855bdb548a9f383a9020b 1 parent da63806
Andriy Gapon authored July 24, 2013

Showing 1 changed file with 2 additions and 3 deletions. Show diff stats Hide diff stats

  1. 5  lib/libc/stdlib/getenv.c
5  lib/libc/stdlib/getenv.c
@@ -505,9 +505,8 @@ __setenv(const char *name, size_t nameLen, const char *value, int overwrite)
505 505
 		envVars[envNdx].valueSize = valueLen;
506 506
 
507 507
 		/* Save name of name/value pair. */
508  
-		env = stpcpy(envVars[envNdx].name, name);
509  
-		if ((envVars[envNdx].name)[nameLen] != '=')
510  
-			env = stpcpy(env, "=");
  508
+		env = stpncpy(envVars[envNdx].name, name, nameLen);
  509
+		*env++ = '=';
511 510
 	}
512 511
 	else
513 512
 		env = envVars[envNdx].value;

0 notes on commit 7d0241f

Please sign in to comment.
Something went wrong with that request. Please try again.