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

Alan Modra amodra@sourceware.org
Sun Aug 23 10:46:53 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=4bc27f4de26cbd254dec1acde15d983f6bea189c

commit 4bc27f4de26cbd254dec1acde15d983f6bea189c
Author: Alan Modra <amodra@gmail.com>
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;


More information about the Binutils-cvs mailing list