We usually call specifier_printf() and then check the validity of the result. In many cases, validity checkers, e.g. path_is_valid(), refuse too long strings. This makes specifier_printf() refuse such long results earlier. Moreover, unit_full_string() and description field in sysuser now refuse results longer than LONG_LINE_MAX. config_parse() already refuses the line longer than LONG_LINE_MAX. Hence, it should be ok to set the same value as the maximum length of the resolved string.
14 lines
580 B
C
14 lines
580 B
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
#pragma once
|
|
|
|
#include "install.h"
|
|
#include "unit-name.h"
|
|
|
|
int install_full_printf_internal(const UnitFileInstallInfo *i, const char *format, size_t max_length, char **ret);
|
|
static inline int install_name_printf(const UnitFileInstallInfo *i, const char *format, char **ret) {
|
|
return install_full_printf_internal(i, format, UNIT_NAME_MAX, ret);
|
|
}
|
|
static inline int install_path_printf(const UnitFileInstallInfo *i, const char *format, char **ret) {
|
|
return install_full_printf_internal(i, format, PATH_MAX-1, ret);
|
|
}
|