[binutils-gdb] objcopy --strip-symbols and similar with file arg

Alan Modra via Binutils-cvs <[email protected]>
Newsgroups gmane.comp.gnu.binutils.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4bc27f4de26cbd254dec1acde15d983f6bea189c

commit 4bc27f4de26cbd254dec1acde15d983f6bea189c
Author: Alan Modra <[email protected]>
Date:   Sun Aug 23 20:04:52 2026 +0930

    objcopy --strip-symbols and similar with file arg
    
    If something like --strip-symbols /dev/urandom is passed to objcopy
    we get a -1 return from get_file_size which isn't checked.  Things go
    downhill from there.
    
            * objcopy.c (add_specific_symbols): Fail on negative return
            from get_file_size.

Diff:
---
 binutils/objcopy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index 4ab7e8997b5..609bb311a9a 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1134,7 +1134,7 @@ add_specific_symbols (const char *filename, htab_t htab, char **buffer_p)
   unsigned int line_count;
 
   size = get_file_size (filename);
-  if (size == 0)
+  if (size < 1)
     {
       status = 1;
       return;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.