diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-07-02 09:39:18 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-07-02 09:39:18 -0700 |
commit | cb88d31c15a2803950e81663e4d808a31ba4f8c0 (patch) | |
tree | 5b71201fa9b454ab8e4e818053455dc9f831f92b /linux/syslinux.c | |
parent | 63a5a1a7cac1147e80534edcef3b410e5a8119b8 (diff) | |
download | syslinux-cb88d31c15a2803950e81663e4d808a31ba4f8c0.tar.gz |
installers: handle asprintf() correctly
It appears that the glibc version of asprintf() is braindamaged, and
doesn't set the target pointer to NULL in the event of an error (only
returns -1). Therefore we need to check the return value. Just in
case someone else made the *opposite* error, also check the pointer.
Bleh. The glibc documentation states that *BSD sets the pointer to
NULL, but instead of following that, the glibc people put
warn_unused_result on asprintf. Sigh.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'linux/syslinux.c')
-rw-r--r-- | linux/syslinux.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/linux/syslinux.c b/linux/syslinux.c index 70fadcd0..9462138f 100644 --- a/linux/syslinux.c +++ b/linux/syslinux.c @@ -261,11 +261,11 @@ int main(int argc, char *argv[]) /* Note: subdir is guaranteed to start and end in / */ if (opt.directory && opt.directory[0]) { int len = strlen(opt.directory); - asprintf(&subdir, "%s%s%s", - opt.directory[0] == '/' ? "" : "/", - opt.directory, - opt.directory[len-1] == '/' ? "" : "/"); - if (!subdir) { + int rv = asprintf(&subdir, "%s%s%s", + opt.directory[0] == '/' ? "" : "/", + opt.directory, + opt.directory[len-1] == '/' ? "" : "/"); + if (rv < 0 || !subdir) { perror(program); exit(1); } |