Skip to content
Closed
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
12 changes: 11 additions & 1 deletion ext/gd/libgd/gdft.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,17 @@ static void *fontFetch (char **error, void *key)
#ifdef NETWARE
if (*name == '/' || (name[0] != 0 && strstr(name, ":/"))) {
#else
if (*name == '/' || (name[0] != 0 && name[1] == ':' && (name[2] == '/' || name[2] == '\\'))) {
/* Actual length doesn't matter, just the minimum does up to length 2. */
unsigned int min_length = 0;
if (name[0] != '\0') {
if (name[1] != '\0') {
min_length = 2;
} else {
min_length = 1;
}
}
ZEND_IGNORE_VALUE(min_length); /* On Posix systems this may be unused */
if (IS_ABSOLUTE_PATH(name, min_length)) {
#endif
snprintf(fullname, sizeof(fullname) - 1, "%s", name);
if (access(fullname, R_OK) == 0) {
Expand Down
28 changes: 28 additions & 0 deletions ext/gd/tests/gh10344.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
--TEST--
GH-10344 (imagettfbbox(): Could not find/open font UNC path)
--EXTENSIONS--
gd
--SKIPIF--
<?php
if (PHP_OS_FAMILY != 'Windows') {
die("skip windows only test");
}
if (!GD_BUNDLED) {
die("skip Not (yet) fixed in libgd itself");
}
if (!function_exists("imagettfbbox")) {
die("skip ttf support unavailable");
}
if (!is_readable("\\\\localhost\\c$\\Windows\\Fonts\\arial.ttf")) {
die("skip font not readable");
}
?>
--FILE--
<?php

$font = '\\\\localhost\\c$\\Windows\\Fonts\\arial.ttf';
var_dump(count(imagettfbbox(10, 0, $font, 'hello')));

?>
--EXPECT--
int(8)