Skip to content

Repo sync for protected CLA branch #3753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/atl-mfc-shared/cstring-argument-passing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ When you define a class interface, you must determine the argument-passing conve

## <a name="_core_strings_as_function_inputs"></a> Strings as Function Inputs

The most efficient and secure way to use a `CString` object in called functions is to pass a `CString` object to the function. Despite the name, a `CString` object doesn't store a string internally as a C-style string that has a `NULL` terminator. Instead, a `CString` object keeps careful track of the number of characters it has. Having `CString` provide a `LPCTSTR` pointer to a `NULL` terminated string is a small amount of work that can become significant if your code has to do it constantly. The result is temporary because any change to the `CString` contents invalidates old copies of the `LPCTSTR` pointer.
The most efficient and secure way to use a `CString` object in called functions is to pass a `CString` object to the function. Despite the name, a `CString` object doesn't store a string internally as a C-style string that has a `NULL` terminator. Instead, a `CString` object keeps careful track of the number of characters it has. Having `CString` provide a `LPCTSTR` pointer to a `NULL`-terminated string is a small amount of work that can become significant if your code has to do it constantly. The result is temporary because any change to the `CString` contents invalidates old copies of the `LPCTSTR` pointer.

It does make sense in some cases to provide a C-style string. For example, there can be a situation where a called function is written in C and doesn't support objects. In this case, coerce the `CString` parameter to `LPCTSTR`, and the function will get a C-style `NULL` terminated string. You can also go the other direction and create a `CString` object by using the `CString` constructor that accepts a C-style string parameter.
It does make sense in some cases to provide a C-style string. For example, there can be a situation where a called function is written in C and doesn't support objects. In this case, coerce the `CString` parameter to `LPCTSTR`, and the function will get a C-style `NULL`-terminated string. You can also go the other direction and create a `CString` object by using the `CString` constructor that accepts a C-style string parameter.

If the string contents are to be changed by a function, declare the parameter as a nonconstant `CString` reference (`CString&`).

Expand Down
2 changes: 1 addition & 1 deletion docs/atl-mfc-shared/string-data-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ helpviewer_keywords: ["Unicode, string objects"]

Visual C++ provides several ways to manage string data:

- [String Manipulation](../c-runtime-library/string-manipulation-crt.md) for working with C-style `NULL` terminated strings
- [String Manipulation](../c-runtime-library/string-manipulation-crt.md) for working with C-style `NULL`-terminated strings

- Win32 API functions for managing strings

Expand Down
32 changes: 16 additions & 16 deletions docs/atl/reference/cregkey-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class CRegKey
When you close a key, its registry data is written (flushed) to the hard disk. This process may take several seconds. If your application must explicitly write registry data to the hard disk, you can call the [`RegFlushKey`](/windows/win32/api/winreg/nf-winreg-regflushkey) Win32 function. However, `RegFlushKey` uses many system resources and should be called only when absolutely necessary.

> [!IMPORTANT]
> Any methods that allow the caller to specify a registry location have the potential to read data that cannot be trusted. Methods that make use of [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) should take into consideration that this function does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> Any methods that allow the caller to specify a registry location have the potential to read data that cannot be trusted. Methods that make use of [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) should take into consideration that this function does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## Requirements

Expand Down Expand Up @@ -469,7 +469,7 @@ LONG QueryBinaryValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query.
Pointer to a `NULL`-terminated string containing the name of the value to query.

*`pValue`*\
Pointer to a buffer that receives the value's data.
Expand All @@ -486,7 +486,7 @@ If the method succeeds, `ERROR_SUCCESS` is returned. If the method fails to read
This method makes use of `RegQueryValueEx` and confirms that the correct type of data is returned. See [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) for more details.

> [!IMPORTANT]
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## <a name="querydwordvalue"></a> `CRegKey::QueryDWORDValue`

Expand All @@ -501,7 +501,7 @@ LONG QueryDWORDValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query.
Pointer to a `NULL`-terminated string containing the name of the value to query.

*`dwValue`*\
Pointer to a buffer that receives the `DWORD`.
Expand All @@ -515,7 +515,7 @@ If the method succeeds, `ERROR_SUCCESS` is returned. If the method fails to read
This method makes use of `RegQueryValueEx` and confirms that the correct type of data is returned. See [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) for more details.

> [!IMPORTANT]
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## <a name="queryguidvalue"></a> `CRegKey::QueryGUIDValue`

Expand All @@ -530,7 +530,7 @@ LONG QueryGUIDValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query.
Pointer to a `NULL`-terminated string containing the name of the value to query.

*`guidValue`*\
Pointer to a variable that receives the GUID.
Expand Down Expand Up @@ -560,10 +560,10 @@ LONG QueryMultiStringValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query.
Pointer to a `NULL`-terminated string containing the name of the value to query.

*`pszValue`*\
Pointer to a buffer that receives the multistring data. A multistring is an array of `NULL` terminated strings, terminated by two null characters.
Pointer to a buffer that receives the multistring data. A multistring is an array of `NULL`-terminated strings, terminated by two null characters.

*`pnChars`*\
The size, in `TCHARs`, of the buffer pointed to by *`pszValue`*. When the method returns, *`pnChars`* contains the size, in `TCHARs`, of the multistring retrieved, including a terminating null character.
Expand All @@ -577,7 +577,7 @@ If the method succeeds, `ERROR_SUCCESS` is returned. If the method fails to read
This method makes use of `RegQueryValueEx` and confirms that the correct type of data is returned. See [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) for more details.

> [!IMPORTANT]
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## <a name="queryqwordvalue"></a> `CRegKey::QueryQWORDValue`

Expand All @@ -592,7 +592,7 @@ LONG QueryQWORDValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query.
Pointer to a `NULL`-terminated string containing the name of the value to query.

*`qwValue`*\
Pointer to a buffer that receives the `QWORD`.
Expand All @@ -606,7 +606,7 @@ If the method succeeds, `ERROR_SUCCESS` is returned. If the method fails to read
This method makes use of `RegQueryValueEx` and confirms that the correct type of data is returned. See [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) for more details.

> [!IMPORTANT]
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## <a name="querystringvalue"></a> `CRegKey::QueryStringValue`

Expand All @@ -622,7 +622,7 @@ LONG QueryStringValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query.
Pointer to a `NULL`-terminated string containing the name of the value to query.

*`pszValue`*\
Pointer to a buffer that receives the string data.
Expand All @@ -639,7 +639,7 @@ If the method succeeds, `ERROR_SUCCESS` is returned. If the method fails to read
This method makes use of `RegQueryValueEx` and confirms that the correct type of data is returned. See [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) for more details.

> [!IMPORTANT]
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the [`RegQueryValueEx`](/windows/win32/api/winreg/nf-winreg-regqueryvalueexw) function used by this method does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## <a name="queryvalue"></a> `CRegKey::QueryValue`

Expand All @@ -665,7 +665,7 @@ ATL_DEPRECATED LONG QueryValue(
### Parameters

*`pszValueName`*\
Pointer to a `NULL` terminated string containing the name of the value to query. If *`pszValueName`* is `NULL` or an empty string, `""`, the method retrieves the type and data for the key's unnamed or default value, if any.
Pointer to a `NULL`-terminated string containing the name of the value to query. If *`pszValueName`* is `NULL` or an empty string, `""`, the method retrieves the type and data for the key's unnamed or default value, if any.

*`pdwType`*\
Pointer to a variable that receives a code indicating the type of data stored in the specified value. The *`pdwType`* parameter can be `NULL` if the type code isn't required.
Expand Down Expand Up @@ -699,7 +699,7 @@ The two original versions of `QueryValue` are no longer supported and are marked
The remaining method calls `RegQueryValueEx`.

> [!IMPORTANT]
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the `RegQueryValueEx` function used by this method does not explicitly handle strings which are `NULL` terminated. Both conditions should be checked for by the calling code.
> This method allows the caller to specify any registry location, potentially reading data which cannot be trusted. Also, the `RegQueryValueEx` function used by this method does not explicitly handle strings which are null-terminated. Both conditions should be checked for by the calling code.

## <a name="recursedeletekey"></a> `CRegKey::RecurseDeleteKey`

Expand Down Expand Up @@ -875,7 +875,7 @@ LONG SetMultiStringValue(LPCTSTR pszValueName, LPCTSTR pszValue) throw();
Pointer to a string containing the name of the value to set. If a value with this name isn't already present, the method adds it to the key.

*`pszValue`*\
Pointer to the multistring data to be stored with the specified value name. A multistring is an array of `NULL` terminated strings, terminated by two null characters.
Pointer to the multistring data to be stored with the specified value name. A multistring is an array of `NULL`-terminated strings, terminated by two null characters.

### Return Value

Expand Down
6 changes: 3 additions & 3 deletions docs/c-runtime-library/exec-wexec-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ Parameters are passed to the new process by giving one or more pointers to chara
> [!IMPORTANT]
> Do not pass user input to `_exec` without explicitly checking its content. `_exec` will result in a call to [`CreateProcess`](/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw) so keep in mind that unqualified path names could lead to potential security vulnerabilities.

The `_exec` functions validate their parameters. If expected parameters are `NULL` pointers, empty strings, or omitted, the `_exec` functions invoke the invalid parameter handler as described in [Parameter Validation](../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions set `errno` to `EINVAL` and return -1. No new process is executed.
The `_exec` functions validate their parameters. If expected parameters are null pointers, empty strings, or omitted, the `_exec` functions invoke the invalid parameter handler as described in [Parameter Validation](../c-runtime-library/parameter-validation.md). If execution is allowed to continue, these functions set `errno` to `EINVAL` and return -1. No new process is executed.

The argument pointers can be passed as separate parameters (in `_execl`, `_execle`, `_execlp`, and `_execlpe`) or as an array of pointers (in `_execv`, `_execve`, `_execvp`, and `_execvpe`). At least one parameter, `arg0`, must be passed to the new process; this parameter is `argv[0]` of the new process. Usually, this parameter is a copy of `cmdname`. (A different value doesn't produce an error.)

The `_execl`, `_execle`, `_execlp`, and `_execlpe` calls are typically used when the number of parameters is known in advance. The parameter `arg0` is usually a pointer to `cmdname`. The parameters `arg1` through `argn` point to the character strings forming the new parameter list. A `NULL` pointer must follow `argn` to mark the end of the parameter list.
The `_execl`, `_execle`, `_execlp`, and `_execlpe` calls are typically used when the number of parameters is known in advance. The parameter `arg0` is usually a pointer to `cmdname`. The parameters `arg1` through `argn` point to the character strings forming the new parameter list. A null pointer must follow `argn` to mark the end of the parameter list.

The `_execv`, `_execve`, `_execvp`, and `_execvpe` calls are useful when the number of parameters to the new process is variable. Pointers to the parameters are passed as an array, `argv`. The parameter `argv[0]` is usually a pointer to `cmdname`. The parameters `argv[1]` through `argv[n]` point to the character strings forming the new parameter list. The parameter `argv[n+1]` must be a **`NULL`** pointer to mark the end of the parameter list.

Files that are open when an `_exec` call is made remain open in the new process. In `_execl`, `_execlp`, `_execv`, and `_execvp` calls, the new process inherits the environment of the calling process. `_execle`, `_execlpe`, `_execve`, and `_execvpe` calls alter the environment for the new process by passing a list of environment settings through the `envp` parameter. `envp` is an array of character pointers, each element of which (except for the final element) points to a `NULL` terminated string defining an environment variable. Such a string usually has the form `NAME=value` where `NAME` is the name of an environment variable and `value` is the string value to which that variable is set. (Note that `value` isn't enclosed in double quotation marks.) The final element of the `envp` array should be **`NULL`**. When `envp` itself is **`NULL`**, the new process inherits the environment settings of the calling process.
Files that are open when an `_exec` call is made remain open in the new process. In `_execl`, `_execlp`, `_execv`, and `_execvp` calls, the new process inherits the environment of the calling process. `_execle`, `_execlpe`, `_execve`, and `_execvpe` calls alter the environment for the new process by passing a list of environment settings through the `envp` parameter. `envp` is an array of character pointers, each element of which (except for the final element) points to a null-terminated string defining an environment variable. Such a string usually has the form `NAME=value` where `NAME` is the name of an environment variable and `value` is the string value to which that variable is set. (Note that `value` isn't enclosed in double quotation marks.) The final element of the `envp` array should be **`NULL`**. When `envp` itself is **`NULL`**, the new process inherits the environment settings of the calling process.

A program executed with one of the `_exec` functions is always loaded into memory as if the maximum allocation field in the program's .exe file header were set to the default value of `0xFFFFH`.

Expand Down
9 changes: 4 additions & 5 deletions docs/c-runtime-library/exit-success-exit-failure.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ title: "EXIT_SUCCESS, EXIT_FAILURE"
ms.date: "06/25/2018"
f1_keywords: ["EXIT_FAILURE", "EXIT_SUCCESS"]
helpviewer_keywords: ["EXIT_SUCCESS constant", "EXIT_FAILURE constant"]
ms.assetid: ff2c82cb-c0bb-4556-a812-59aa278bfac5
---
# EXIT_SUCCESS, EXIT_FAILURE
# `EXIT_SUCCESS`, `EXIT_FAILURE`

## Required header

Expand All @@ -16,12 +15,12 @@ ms.assetid: ff2c82cb-c0bb-4556-a812-59aa278bfac5

## Remarks

These are arguments for the [exit](reference/exit-exit-exit.md) and [_exit](reference/exit-exit-exit.md) functions, and the return values for the [atexit](reference/atexit.md) and [_onexit](reference/onexit-onexit-m.md) functions.
These are arguments for the [`exit`](reference/exit-exit-exit.md) and [`_exit`](reference/exit-exit-exit.md) functions, and the return values for the [`atexit`](reference/atexit.md) and [`_onexit`](reference/onexit-onexit-m.md) functions.

|Constant|Defined value|
|-|-|
|EXIT_SUCCESS|0|
|EXIT_FAILURE|1|
|`EXIT_SUCCESS`|0|
|`EXIT_FAILURE`|1|

## See also

Expand Down
2 changes: 1 addition & 1 deletion docs/c-runtime-library/filename-search-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Time of the last write to file. This time is stored in UTC format. To convert to
Length of the file in bytes.

`char name`[ `_MAX_PATH`]
`NULL` terminated name of matched file or directory, without the path.
`NULL`-terminated name of matched file or directory, without the path.

In file systems that don't support the creation and last access times of a file, such as the FAT system, the `time_create` and `time_access` fields are always `-1L`.

Expand Down
Loading