nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Stebalien/tempfile
Pull request #278 (2024-02-26 20:29:12)

Fix integer overflows and truncation
Make sure that calculations do not overflow.
Also do not truncate u64 to usize on 32 bit systems.

I have added tests to showcase the issues.


Patch:
diff --git a/src/spooled.rs b/src/spooled.rs
index 2c8eaa4..9b2e7e7 100644
--- a/src/spooled.rs
+++ b/src/spooled.rs
@@ -96,7 +96,7 @@ impl SpooledTempFile {
     }
 
     pub fn set_len(&mut self, size: u64) -> Result<(), io::Error> {
-        if size as usize > self.max_size {
+        if size > self.max_size as u64 {
             self.roll()?; // does nothing if already rolled over
         }
         match &mut self.inner {
@@ -157,7 +157,7 @@ impl Write for SpooledTempFile {
         // roll over to file if necessary
         if matches! {
             &self.inner, SpooledData::InMemory(cursor)
-            if cursor.position() as usize + buf.len() > self.max_size
+            if cursor.position().saturating_add(buf.len() as u64) > self.max_size as u64
         } {
             self.roll()?;
         }
@@ -173,8 +173,10 @@ impl Write for SpooledTempFile {
         if matches! {
             &self.inner, SpooledData::InMemory(cursor)
             // Borrowed from the rust standard library.
-            if cursor.position() as usize + bufs.iter()
-                .fold(0usize, |a, b| a.saturating_add(b.len())) > self.max_size
+            if bufs
+                .iter()
+                .fold(cursor.position(), |a, b| a.saturating_add(b.len() as u64))
+                > self.max_size as u64
         } {
             self.roll()?;
         }
diff --git a/src/util.rs b/src/util.rs
index 8c04953..e91150f 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -5,7 +5,11 @@ use std::{io, iter::repeat_with};
 use crate::error::IoResultExt;
 
 fn tmpname(prefix: &OsStr, suffix: &OsStr, rand_len: usize) -> OsString {
-    let mut buf = OsString::with_capacity(prefix.len() + suffix.len() + rand_len);
+    let capacity = prefix
+        .len()
+        .saturating_add(suffix.len())
+        .saturating_add(rand_len);
+    let mut buf = OsString::with_capacity(capacity);
     buf.push(prefix);
     let mut char_buf = [0u8; 4];
     for c in repeat_with(fastrand::alphanumeric).take(rand_len) {


Test patch:
diff --git a/tests/spooled.rs b/tests/spooled.rs
index a3bcc03..4060214 100644
--- a/tests/spooled.rs
+++ b/tests/spooled.rs
@@ -305,3 +305,18 @@ fn test_set_len_rollover() {
     assert_eq!(t.read_to_end(&mut buf).unwrap(), 20);
     assert_eq!(buf.as_slice(), b"abcde\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
 }
+
+#[test]
+fn test_write_overflow() {
+    let mut t = spooled_tempfile(10);
+    t.seek(SeekFrom::Start(u64::MAX)).unwrap();
+    assert!(t.write(b"abcde").is_err());
+}
+
+#[cfg(target_pointer_width = "32")]
+#[test]
+fn test_set_len_truncation() {
+    let mut t = spooled_tempfile(100);
+    assert!(t.set_len(usize::MAX as u64 + 5).is_ok());
+    assert!(t.is_rolled());
+}
Repository: Stebalien/tempfile
Pull request #349 (2025-05-10 15:16:56)

feat: rename `TempDir::into_path` to `TempDir::keep`
This unifies the `TempDir`/`NamedTempFile` method names to help avoid confusion.


Patch:
diff --git a/src/dir/mod.rs b/src/dir/mod.rs
index 4b0c37a..fa8d7e4 100644
--- a/src/dir/mod.rs
+++ b/src/dir/mod.rs
@@ -382,6 +382,13 @@ impl TempDir {
         self.path.as_ref()
     }
 
+    /// Deprecated alias for [`TempDir::keep`].
+    #[must_use]
+    #[deprecated = "use TempDir::keep()"]
+    pub fn into_path(self) -> PathBuf {
+        self.keep()
+    }
+
     /// Persist the temporary directory to disk, returning the [`PathBuf`] where it is located.
     ///
     /// This consumes the [`TempDir`] without deleting directory on the filesystem, meaning that
@@ -400,14 +407,13 @@ impl TempDir {
     ///
     /// // Persist the temporary directory to disk,
     /// // getting the path where it is.
-    /// let tmp_path = tmp_dir.into_path();
+    /// let tmp_path = tmp_dir.keep();
     ///
     /// // Delete the temporary directory ourselves.
     /// fs::remove_dir_all(tmp_path)?;
     /// # Ok::<(), std::io::Error>(())
     /// ```
-    #[must_use]
-    pub fn into_path(self) -> PathBuf {
+    pub fn keep(self) -> PathBuf {
         // Prevent the Drop impl from being called.
         let mut this = mem::ManuallyDrop::new(self);
 
diff --git a/src/lib.rs b/src/lib.rs
index f5665a6..9fadcfe 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -469,7 +469,8 @@ impl<'a, 'b> Builder<'a, 'b> {
     /// [`NamedTempFile`]/[`TempDir`]. When `keep` is set to `true`, this behavior is suppressed.
     ///
     /// If you wish to keep a temporary file or directory after creating it, call
-    /// [`NamedTempFile::keep`] or [`TempDir::into_path`] respectively.
+    /// [`NamedTempFile::keep`] or [`TempDir::keep`] respectively to turn it into a regular
+    /// file/path (respectively) that won't be automatically deleted.
     ///
     /// # Examples
     ///


Test patch:
diff --git a/tests/tempdir.rs b/tests/tempdir.rs
index b427e67..59e7f05 100644
--- a/tests/tempdir.rs
+++ b/tests/tempdir.rs
@@ -85,7 +85,7 @@ fn test_rm_tempdir() {
     let path;
     {
         let tmp = TempDir::new().unwrap();
-        path = tmp.into_path();
+        path = tmp.keep();
     }
     assert!(path.exists());
     fs::remove_dir_all(&path).unwrap();
@@ -128,7 +128,7 @@ fn test_rm_tempdir_close() {
     let path;
     {
         let tmp = TempDir::new().unwrap();
-        path = tmp.into_path();
+        path = tmp.keep();
     }
     assert!(path.exists());
     fs::remove_dir_all(&path).unwrap();
Repository: xerial/sqlite-jdbc
Pull request #844 (2023-02-28 16:03:54)

feat(SQLiteDataSource): add setBusyTimeout
add SQLiteDataSource.setBusyTimeout(int milliseconds) so that we can do:
```
    final SQLiteDataSource ds = new SQLiteDataSource();
    ds.setBusyTimeout(1234);
```

instead of doing like below, or setting up a Properties object and providing it to the SQLiteDataSource constructor:

```
    final SQLiteDataSource ds = new SQLiteDataSource();
    ds.getConfig().setBusyTimeout(2000);
```

Note that the new test will fail because it depends on the change made by https://github.com/xerial/sqlite-jdbc/pull/843.

Without that fix, the line `assertThat(ds.getConfig().getBusyTimeout()).isEqualTo(1234);` in the new test will fail.

mruddy: just added a second commit that adds (somewhat crazy looking) source code formatting updates generated `by running mvn spotless:apply`

Patch:
diff --git a/src/main/java/org/sqlite/SQLiteDataSource.java b/src/main/java/org/sqlite/SQLiteDataSource.java
index 2b6f608a..26004c01 100755
--- a/src/main/java/org/sqlite/SQLiteDataSource.java
+++ b/src/main/java/org/sqlite/SQLiteDataSource.java
@@ -139,6 +139,17 @@ public class SQLiteDataSource implements DataSource {
         config.setReadOnly(readOnly);
     }
 
+    /**
+     * Sets the amount of time that the connection's busy handler will wait when a table is locked.
+     *
+     * @param milliseconds The number of milliseconds to wait.
+     * @see <a
+     *     href="https://www.sqlite.org/pragma.html#pragma_busy_timeout">https://www.sqlite.org/pragma.html#pragma_busy_timeout</a>
+     */
+    public void setBusyTimeout(int milliseconds) {
+        config.setBusyTimeout(milliseconds);
+    }
+
     /**
      * Sets the suggested maximum number of database disk pages that SQLite will hold in memory at
      * once per open database file.


Test patch:
diff --git a/src/test/java/org/sqlite/SQLiteDataSourceTest.java b/src/test/java/org/sqlite/SQLiteDataSourceTest.java
index b3717246..b7674644 100755
--- a/src/test/java/org/sqlite/SQLiteDataSourceTest.java
+++ b/src/test/java/org/sqlite/SQLiteDataSourceTest.java
@@ -80,4 +80,16 @@ public class SQLiteDataSourceTest {
             }
         }
     }
+
+    @Test
+    public void setBusyTimeout() {
+        final SQLiteDataSource ds = new SQLiteDataSource();
+        ds.setBusyTimeout(1234);
+        assertThat(
+                        ds.getConfig()
+                                .toProperties()
+                                .getProperty(SQLiteConfig.Pragma.BUSY_TIMEOUT.pragmaName))
+                .isEqualTo("1234");
+        assertThat(ds.getConfig().getBusyTimeout()).isEqualTo(1234);
+    }
 }
Repository: xerial/sqlite-jdbc
Pull request #1281 (2025-06-09 00:22:03)

fix#1279
[Fix#1279](https://github.com/xerial/sqlite-jdbc/issues/1279)

Fix the use of [ResultSetMetaData.getCatalogName(int column)](https://docs.oracle.com/javase/8/docs/api/java/sql/ResultSetMetaData.html#getCatalogName-int-) method

gotson: thanks for the PR.

if there was no unit test coverage, can this be added ?
prrvchr: Ok done;

```
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 4.535 s -- in org.sqlite.architecture.TestCodingRulesTest
[INFO] 
[INFO] Results:
[INFO] 
[WARNING] Tests run: 443, Failures: 0, Errors: 0, Skipped: 8
[INFO] 
[INFO] 
[INFO] --- maven-jar-plugin:3.4.2:jar (default-jar) @ sqlite-jdbc ---
[INFO] Building jar: /ssd/home/prrvchr/github/sqlite/sqlite-jdbc/target/sqlite-jdbc-3.49.1.1-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  58.959 s
[INFO] Finished at: 2025-06-09T05:50:18+02:00
[INFO] ------------------------------------------------------------------------
```


Patch:
diff --git a/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java b/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java
index 76471128..19f5848e 100644
--- a/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java
+++ b/src/main/java/org/sqlite/jdbc3/JDBC3ResultSet.java
@@ -573,7 +573,7 @@ public abstract class JDBC3ResultSet extends CoreResultSet {
 
     /** @see java.sql.ResultSetMetaData#getCatalogName(int) */
     public String getCatalogName(int col) throws SQLException {
-        return safeGetColumnTableName(col);
+        return "";
     }
 
     /** @see java.sql.ResultSetMetaData#getColumnClassName(int) */


Test patch:
diff --git a/src/test/java/org/sqlite/RSMetaDataTest.java b/src/test/java/org/sqlite/RSMetaDataTest.java
index 950061ef..f7992a9c 100644
--- a/src/test/java/org/sqlite/RSMetaDataTest.java
+++ b/src/test/java/org/sqlite/RSMetaDataTest.java
@@ -43,7 +43,12 @@ public class RSMetaDataTest {
 
     @Test
     public void catalogName() throws SQLException {
-        assertThat(meta.getCatalogName(1)).isEqualTo("People");
+        assertThat(meta.getCatalogName(1)).isEqualTo("");
+    }
+
+    @Test
+    public void schemaName() throws SQLException {
+        assertThat(meta.getSchemaName(1)).isEqualTo("");
     }
 
     @Test
@@ -196,8 +201,8 @@ public class RSMetaDataTest {
     }
 
     @Test
-    public void badCatalogIndex() {
-        assertThatExceptionOfType(SQLException.class).isThrownBy(() -> meta.getCatalogName(4));
+    public void badTableIndex() {
+        assertThatExceptionOfType(SQLException.class).isThrownBy(() -> meta.getTableName(5));
     }
 
     @Test
Repository: google/pprof
Pull request #892 (2024-09-03 15:28:49)

Added doc link to profile header.
Output looks something like:

```
% pprof -top ...
File: ...
Build ID: ...
Type: cpu
Doc: http://example.com/cpuprofile
Duration: 6.71s, Total samples = 5.72s (85.30%)
Showing nodes accounting for 5.17s, 90.38% of 5.72s total
Dropped 326 nodes (cum <= 0.03s)
...
```


Patch:
diff --git a/internal/report/report.go b/internal/report/report.go
index 7035e23..5ab0da6 100644
--- a/internal/report/report.go
+++ b/internal/report/report.go
@@ -1169,6 +1169,9 @@ func ProfileLabels(rpt *Report) []string {
 	if o.SampleType != "" {
 		label = append(label, "Type: "+o.SampleType)
 	}
+	if url := prof.DocURL; url != "" {
+		label = append(label, "Doc: "+url)
+	}
 	if prof.TimeNanos != 0 {
 		const layout = "Jan 2, 2006 at 3:04pm (MST)"
 		label = append(label, "Time: "+time.Unix(0, prof.TimeNanos).Format(layout))


Test patch:
diff --git a/internal/report/report_test.go b/internal/report/report_test.go
index 08ce9da..845c369 100644
--- a/internal/report/report_test.go
+++ b/internal/report/report_test.go
@@ -16,6 +16,7 @@ package report
 
 import (
 	"bytes"
+	"fmt"
 	"os"
 	"path/filepath"
 	"regexp"
@@ -576,3 +577,21 @@ func TestDocURL(t *testing.T) {
 		})
 	}
 }
+
+func TestDocURLInLabels(t *testing.T) {
+	const url = "http://example.com/pprof-help"
+	profile := testProfile.Copy()
+	profile.DocURL = url
+	rpt := New(profile, &Options{
+		OutputFormat: Text,
+		Symbol:       regexp.MustCompile(`.`),
+		TrimPath:     "/some/path",
+		SampleValue:  func(v []int64) int64 { return v[1] },
+		SampleUnit:   testProfile.SampleType[1].Unit,
+	})
+
+	labels := fmt.Sprintf("%v", ProfileLabels(rpt))
+	if !strings.Contains(labels, url) {
+		t.Errorf("expected URL %q not found in %s", url, labels)
+	}
+}
Repository: google/pprof
Pull request #899 (2024-09-27 20:51:32)

Report missing file name as "", not "."

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/google/pprof/pull/899?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 66.96%. Comparing base [(`0ed6a68`)](https://app.codecov.io/gh/google/pprof/commit/0ed6a68c8d9e6d5df69a1f2694c7b5c3297fdf4f?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) to head [(`d3c3427`)](https://app.codecov.io/gh/google/pprof/commit/d3c342702e3c97045bb7013a76dec97e9b0464f9?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).
> Report is 39 commits behind head on main.

<details><summary>Additional details and impacted files</summary>


```diff
@@            Coverage Diff             @@
##             main     #899      +/-   ##
==========================================
+ Coverage   66.86%   66.96%   +0.09%     
==========================================
  Files          44       44              
  Lines        9824     9855      +31     
==========================================
+ Hits         6569     6599      +30     
- Misses       2794     2806      +12     
+ Partials      461      450      -11     
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/google/pprof/pull/899?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google).


Patch:
diff --git a/internal/report/shortnames.go b/internal/report/shortnames.go
index 438624e..4663573 100644
--- a/internal/report/shortnames.go
+++ b/internal/report/shortnames.go
@@ -29,6 +29,10 @@ var (
 // fileNameSuffixes returns a non-empty sequence of shortened file names
 // (in decreasing preference) that can be used to represent name.
 func fileNameSuffixes(name string) []string {
+	if name == "" {
+		// Avoid returning "." when symbol info is missing
+		return []string{""}
+	}
 	return allSuffixes(filepath.ToSlash(filepath.Clean(name)), fileSepRE)
 }
 


Test patch:
diff --git a/internal/report/shortnames_test.go b/internal/report/shortnames_test.go
index 01cbcff..820cd4d 100644
--- a/internal/report/shortnames_test.go
+++ b/internal/report/shortnames_test.go
@@ -44,7 +44,7 @@ func TestFileNameSuffixes(t *testing.T) {
 	}
 
 	for _, c := range []testCase{
-		test("empty", "", "."),
+		test("empty", "", ""),
 		test("simple", "foo", "foo"),
 		test("manypaths", "a/b/c", "a/b/c", "b/c", "c"),
 		test("leading", "/a/b", "/a/b", "a/b", "b"),