-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is like strdupa(3), but we make sure that the argument is a string literal, which makes sure that we won't have a stack overflow. Signed-off-by: Alejandro Colomar <alx@kernel.org>
- Loading branch information
1 parent
3f34129
commit dd4fa7b
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#include <config.h> | ||
|
||
#include "string/strdup/strdupa.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// SPDX-FileCopyrightText: 2025, Alejandro Colomar <alx@kernel.org> | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
|
||
#ifndef SHADOW_INCLUDE_LIB_STRING_STRDUP_STRDUPA_H_ | ||
#define SHADOW_INCLUDE_LIB_STRING_STRDUP_STRDUPA_H_ | ||
|
||
|
||
#include <config.h> | ||
|
||
#include <string.h> | ||
|
||
|
||
// strdupa(3), but make sure that the argument is a string literal. | ||
#define STRDUPA(s) strdupa("" s "") | ||
|
||
|
||
#endif // include guard |