387 Commits

Author SHA1 Message Date
Alan Coopersmith
2c2e44c94e libXfont2 2.0.7
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont2-2.0.7
2024-08-01 15:53:10 -07:00
Enrico Weigelt, metux IT consult
dbc2fbc582 include: libxfont2: fix missing includes of fontproto.h
* needs types from X11/fonts/fontproto.h (eg. NameCheckFunc) from this header,
but forgot to include it.
* needs NULL, which is defined in stddef.h

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxfont/-/merge_requests/28>
2024-07-19 13:35:11 +02:00
José Expósito
0006737243 stubs/atom.c: Fix memory leak in __libxfont_internal__MakeAtom
Reported by a static analysis tool:

     9. libXfont2-2.0.6/src/stubs/atom.c:179:5:
        alloc_fn: Storage is returned from allocation function "malloc".
    10. libXfont2-2.0.6/src/stubs/atom.c:179:5:
        var_assign: Assigning: "a" = storage returned from
        "malloc(24UL + len + 1UL)".
    16. libXfont2-2.0.6/src/stubs/atom.c:194:6:
        leaked_storage: Variable "a" going out of scope leaks the
        storage it points to.
    #   192|  if ((ResizeHashTable() == FALSE) &&
    #   193|     ((hashTable == NULL) || (hashUsed == hashSize)))
    #   194|-> 	 return None;
    #   195|  h = hash & hashMask;
    #   196|  if (hashTable[h]) {

Fixes: 78085e6b68 ("stubs/atom.c: check for ResizeHashTable failure")
Part-of: <https://gitlab.freedesktop.org/xorg/lib/libxfont/-/merge_requests/27>
2024-07-01 16:28:12 +02:00
Alan Coopersmith
c47d610ae2 Use autoconf to check for float.h instead of platform-specific ifdefs
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-17 12:56:52 -08:00
Alan Coopersmith
3d41257544 unifdef NCD
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-17 12:25:15 -08:00
Alan Coopersmith
bac7adac9a unifdef Lynx
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-17 12:22:09 -08:00
Alan Coopersmith
1f7b4edf09 unifdef ISC
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-17 12:21:15 -08:00
Alan Coopersmith
e38d1d27a1 unifdef __OSF1__
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-17 12:20:37 -08:00
Alan Coopersmith
24951703b7 unifdef sony
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-17 12:19:18 -08:00
Alan Coopersmith
c908d2773a bitscale.c: remove unused MAX() macro
Code that used it was removed in commit 632a2e90a4

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-03 02:48:03 +00:00
Alan Coopersmith
0be12a9f7c bitscale.c: ensure SCORE macro expands properly
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-03 02:48:03 +00:00
Alan Coopersmith
42d2b5add5 bitscale.c: ensure SCORE2 macro expands properly
Handles warning from Oracle Parfait 11.2 static analyzer:

Error: Misleading macro
   Misleading macro [misleading-macro]:
      misleading evaluation of '/' operator in expansion of macro SCORE2 due to missing parentheses
        at line 299 of src/bitmap/bitscale.c.
        '/' operator has lower precedence than '/' operator inside macro body at line 438
        low precedence '/' operator is hidden by expansion of macro argument m at line 299
   Misleading macro [misleading-macro]:
      misleading evaluation of '/' operator in expansion of macro SCORE2 due to missing parentheses
        at line 299 of src/bitmap/bitscale.c.
        binary '*' operator has lower precedence than '/' operator inside macro body at line 440
        low precedence binary '*' operator is hidden by expansion of macro argument m at line 299

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-02-03 02:48:03 +00:00
Alan Coopersmith
87b05995a8 configure: Use AC_SYS_LARGEFILE to enable large file support
While font files should never be more than 2gb in size, they may be
stored on filesystems with large inodes or timestamps outside of the
32-bit range.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-01-24 17:44:38 -08:00
Alan Coopersmith
b4b35189d5 Modernize lseek() calls
Position should be stored in an off_t, not an int, and the
"whence" arg should use symbolic constants instead of raw numbers.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2024-01-24 17:42:19 -08:00
Alan Coopersmith
c0ab2a2c42 Set close-on-exec when opening fonts.dir & fonts.alias files
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-03-25 10:40:19 -07:00
Alan Coopersmith
a5ee0e9ab9 configure: Use LT_INIT from libtool 2 instead of deprecated AC_PROG_LIBTOOL
AC_PROG_LIBTOOL was replaced by LT_INIT in libtool 2 in 2008,
so it's time to rely on it.

Clears autoconf warnings:

configure.ac:38: warning: The macro `AC_PROG_LIBTOOL' is obsolete.
configure.ac:38: You should run autoupdate.
aclocal.m4:3640: AC_PROG_LIBTOOL is expanded from...
configure.ac:38: the top level

libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac,
libtoolize: and rerunning libtoolize and aclocal.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-03-04 15:18:07 -08:00
Alan Coopersmith
a3a85df9a6 Remove "All rights reserved" from Oracle copyright notices
Oracle no longer includes this term in our copyright & license notices.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-02-25 09:26:20 -08:00
Alan Coopersmith
0bee036267 configure: raise minimum autoconf requirement to 2.70
Needed for builds on NetBSD to work correctly, since it depends on
AC_USE_SYSTEM_EXTENSIONS defining _OPENBSD_SOURCE to expose the
prototype for reallocarray() in the system headers.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2023-02-16 19:02:29 -08:00
Jeremy Huddleston Sequoia
572d9d52f4 atom: Update Hash() to be unsigned
This avoids undefined behavior (left shift overflow in signed integer type)

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2022-11-26 22:35:40 -08:00
Peter Harris
5ca90ec866 Fix font server reconnection timeout
The great libxfont2 rewrite 135fb032e9 split
fs_wakeup into fs_wakeup and fs_fd_handler. The fs_fd_handler side is
called when there is new data on the socket. The fs_wakeup side is called
on a timeout.

If there's a connection timeout, the block handler will set the timeout
to zero, expecting fs_wakeup to handle the timeout. Therefore, we need to
call _fs_check_reconnect in fs_wakeup to handle the connection timeout.
If we don't, the X server will go to 100% CPU (and the font server
connection will not be retried).

Signed-off-by: Peter Harris <pharris@opentext.com>
2022-11-10 18:12:20 +00:00
Alan Coopersmith
644bea5c48 Only link with libbsd if needed for reallocarray() or strlcat()
Avoid unnecessary library dependency when using a libc with these
functions included

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-11-05 09:16:14 -07:00
Guillem Jover
f476c0a09c Switch from libbsd to libbsd-overlay
This is the preferred usage form for libbsd, as it makes the code more
portable and requires no special includes for libbsd, by transparently
injects the needed standard headers that would be used on a BSD.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2022-10-06 00:39:38 +00:00
Alan Coopersmith
d54aaf2483 libXfont2 2.0.6
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont2-2.0.6
2022-08-26 16:22:15 -07:00
Peter Harris
efb2872236 Fix buffer overrun in FontFileMakeDir on WIN32
When dirName is "" (eg. when called by BuiltinReadDirectory),
FontFileMakeDir would read after the string when WIN32 is defined.

Fix the overrun issue by checking the location of the found :
before adding two.

Signed-off-by: Peter Harris <pharris@opentext.com>
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-08-11 15:02:21 -07:00
Alan Coopersmith
3c8fdf6e35 Fix comments to reflect removal of OS/2 support
Commit 6c29007756 removed OS/2 support from the code,
but missed updating the comments to match.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-06-21 17:37:32 -07:00
Jeremy Huddleston Sequoia
8e3d94c867 Correct fsCreateACReq length
Regressed-in: 6972ea08ee
Fixes: https://gitlab.freedesktop.org/xorg/lib/libxfont/-/issues/13
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
2022-06-21 23:50:14 +00:00
Alan Coopersmith
5cb3b8809b configure: Use pkg-config to handle zlib dependency if possible
Preserves fallback for systems like darwin without zlib.pc

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-06-20 12:30:41 -07:00
Alan Coopersmith
12bed78985 Fix spelling/wording issues
Found by using:
    codespell --builtin clear,rare,usage,informal,code,names

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-04-06 14:37:42 -07:00
Alan Coopersmith
f83ea5e953 Build xz tarballs instead of bzip2
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-04-06 14:31:49 -07:00
Alan Coopersmith
a6aee4c9a4 gitlab CI: add a basic build test
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2022-04-06 14:31:29 -07:00
Alan Coopersmith
3a4f68284c libXfont2 2.0.5
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont2-2.0.5
2021-08-01 17:36:43 -07:00
Alex Richardson
daff887637 Fix out-of-bounds read in FontFileMakeDir()
BuiltinReadDirectory() calls FontFileMakeDir ("", builtin_dir_count); and
this causes the `dirName[dirlen - 1]` access to read before the start of
the string. I found this while porting Xvnc to CHERI-RISC-V (which has
bounds and permissions on all pointers).
2021-07-14 17:23:48 +01:00
Bernd Kuhls
ce7a326501 configure: define HAVE_LIBBSD when libbsd was found 2021-06-12 16:46:17 -07:00
Peter Harris
9529d2351f Fix use after free when font server connection lost
If there are multiple blocks waiting for the same font, only one of them
will have ->freeFont set. The rest will be in a state of FS_DEPENDING.

If the font server dies before the font finishes opening, the block with
->freeFont set will call ->unload_font, invalidating the pfont pointers
in the remaining FS_DEPENDING blocks.

Avoid a use after free (and potential crash) by passing conn to
fs_cleanup_font instead of dereferencing pfont to find the conn.

Signed-off-by: Peter Harris <pharris@opentext.com>
2021-03-02 14:43:55 -05:00
Peter Harris
e7b2cae1ad Fix crash when font server connection lost
Always initialize the return value of fs_new_block_rec. Even if the
conn->blockState is FS_BROKEN_CONNECTION | FS_RECONNECTING, we must not
return with an uninitialized blockrec on the block list. When the
blockrec times out, _fs_clean_aborted_blockrec calls fs_cleanup_bfont,
which will try to follow pointers in the blockrec (which has not been
initialized).

Signed-off-by: Peter Harris <pharris@opentext.com>
2020-03-06 10:42:03 -05:00
Jon Turney
608640b87d Fix Win32 build since c4ed2e06 "Add some unit testing utilities"
Provide Win32 replacements for realpath() and err.h
2019-10-25 18:37:51 +01:00
Adam Jackson
13ebb8f32f README: Remove mention of libXfont 1.5
xfs was ported to libXfont2 in release 1.2, and bdftopcf 1.1 includes a
copy of enough of the old libXfont1 code to not need an external
libXfont at all.
2019-09-16 10:47:27 -04:00
Alan Coopersmith
ed8b8e9fe5 libXfont2 2.0.4
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
libXfont2-2.0.4
2019-09-14 11:34:03 -07:00
Alan Coopersmith
b46cd2fef2 Add src/util/replace.h to noinst_HEADERS so it gets included in tarballs
Found when "make distcheck" failed.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-09-14 11:32:56 -07:00
Alan Coopersmith
5561a9dc83 fs_read_glyphs: check if rep is null before dereferencing
Resolves coverity warning def16 from the list in
https://gitlab.freedesktop.org/xorg/lib/libxfont/issues/6

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-17 14:31:24 -07:00
Alan Coopersmith
c84ce6be6a CatalogueRescan: if opendir() fails, unref fpes, but don't free the cat
None of the callers of CatalogueRescan check for failure before accessing
the cat pointer so don't free it (especially without clearing the pointer
to it in fpe->private), just unref the contents.

Can only be triggered if somehow stat() succeeds on the directory, but
opendir fails anyway (removed between the calls?  permission problem?).

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-17 14:19:04 -07:00
Alan Coopersmith
c1c5c9aa4c ComputeScaledProperties: check for valid pointers before making atoms
Resolves coverity warning def23 from the list in
https://gitlab.freedesktop.org/xorg/lib/libxfont/issues/6

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-17 13:56:03 -07:00
Alan Coopersmith
78085e6b68 stubs/atom.c: check for ResizeHashTable failure
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-17 13:42:39 -07:00
Maya Rashish
3e0e36e4a9 Fix whitespace 2019-08-17 19:51:19 +00:00
Alan Coopersmith
194cb45ceb fontxlfd.c: tell gcc that switch fallthrough is intentional
Quiets:
src/util/fontxlfd.c: In function ‘FontParseXLFDName’:
src/util/fontxlfd.c:450:14: warning: this statement may fall through [-Wimplicit-fallthrough=]
  replaceChar = '*';
  ~~~~~~~~~~~~^~~~~
src/util/fontxlfd.c:451:5: note: here
     case FONT_XLFD_REPLACE_ZERO:
     ^~~~

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-04 11:23:33 -07:00
Alan Coopersmith
ddbee30d35 Convert multiplying malloc calls to use mallocarray instead
Introduces mallocarray as a macro calling reallocarray with a NULL
pointer for the old allocation.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-04 11:23:20 -07:00
Alan Coopersmith
f54470dab5 Convert multiplying realloc calls to use reallocarray instead
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-03 19:31:14 -07:00
Alan Coopersmith
27207d35d4 Add reallocarray fallback if not provided by libc nor libbsd
Implementation copied from the Xserver

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-03 19:31:14 -07:00
Alan Coopersmith
2178c7445a Use bounds checking string functions everywhere
Replace strcpy, strcat, sprintf with strlcpy, strlcat, snprintf
everywhere, even where there were already bounds checks in place,
to reduce time spent checking static analysis results.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-03 19:31:14 -07:00
Alan Coopersmith
d4c941ea8b Add strlcat & strlcpy fallbacks if not provided by libc nor libbsd
Implementations copied from the Xserver

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2019-08-03 17:12:12 -07:00